--- a/src/catedit/models.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/models.py Wed Apr 15 02:48:22 2015 +0200
@@ -97,14 +97,14 @@
Returns category property list
"""
return [
- predicate_object_tuple for predicate_object_tuple in self.cat_graph.predicate_objects()
+ predicate_object_tuple for predicate_object_tuple in self.cat_graph.predicate_objects()
if (
- predicate_object_tuple[0]!=RDF.ID and
+ predicate_object_tuple[0]!=RDF.ID and
predicate_object_tuple[0]!=RDFS.label and
predicate_object_tuple[0]!=RDF.Description
)
]
-
+
def edit_category(self, new_label="",
new_description="",
new_other_properties=None):
@@ -137,11 +137,6 @@
RDF.Description,
Literal(new_description)))
- logger.debug("current properties: "
- + str(self.properties)
- + " new properties: "
- + str(new_other_properties))
-
if new_other_properties is not None and \
(new_other_properties != self.properties):
for (predicate, object) in self.cat_graph.predicate_objects():
@@ -211,10 +206,6 @@
modified_cat_dict = {}
if deleted_cat_dict is None:
deleted_cat_dict = {}
- logger.debug("Calling persistance save method - deleted list is "
- + str(deleted_cat_dict)
- + " and modified list is "
- + str(modified_cat_dict))
self.persistence.save(deletion_dict=deleted_cat_dict,
modification_dict=modified_cat_dict,
message=message)
--- a/src/catedit/persistence.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/persistence.py Wed Apr 15 02:48:22 2015 +0200
@@ -346,12 +346,6 @@
# Now we loop over modified categories to find the ones that don't
# exist yet in the last commit tree in order to create blobs for them
for (cat_name, cat_content) in modification_dict.items():
- logger.debug(app.config["PERSISTENCE_CONFIG"]
- ["CATEGORIES_PATH"]
- + cat_name
- + " should not be in "
- + str([elt["path"] for
- elt in last_commit_tree["tree"]]))
if (app.config["PERSISTENCE_CONFIG"]
["CATEGORIES_PATH"] + cat_name not in
[elt["path"] for elt in last_commit_tree["tree"]]):
@@ -403,7 +397,7 @@
)
logger.error(ghe.response.text)
#TODO: vérifier encoding - logger.debug(str(new_tree_response[0]["sha"]))
-
+
# Point 5
new_commit_data = {"message": kwargs["message"],
"parents": [last_commit_master["sha"]],
--- a/src/catedit/resources.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/resources.py Wed Apr 15 02:48:22 2015 +0200
@@ -34,10 +34,10 @@
The result of this API function goes into the Flask Cache.
"""
-
+
# Cache key for this function and parameters
cache_key = "categoryapi_get_" + repository + "_" + cat_id
-
+
# Cache key for category key registry for this repo
registry_key = "categories_"+repository+"_keys"
if (cache.get(registry_key) is None or cache_key not in cache.get(registry_key)) and cache.get(cache_key) is None:
@@ -74,7 +74,6 @@
key_list = cache.get(registry_key)
key_list.append(cache_key)
cache.set(registry_key, key_list)
- logger.debug("list of key for "+registry_key+" registry: "+str(cache.get(registry_key)))
return rv
else:
return cache.get(cache_key)
@@ -121,7 +120,7 @@
queue="repo_"+repository,
routing_key="task_for_"+repository
)
-
+
session.setdefault("tasks", {}).setdefault(repository, []).append(task.id)
session.setdefault("deleted_categories", {})[repository] = {}
session.setdefault("modified_categories", {})[repository] = {}
@@ -141,7 +140,7 @@
cat = Category(graph=cat_graph)
else:
cat = cat_manager_instance.load_category(cat_id)
-
+
new_property_list=[]
for (predicate, obj) in cat_data["properties"]:
if get_property_list()[repository].get(predicate, {}).get("object_type") == "uriref-category":
@@ -155,7 +154,7 @@
new_property_list.append(
(URIRef(get_property_list()[repository][predicate]["rdflib_class"]), Literal(obj))
)
-
+
cat.edit_category(new_description=cat_data["description"],
new_label=cat_data["label"],
new_other_properties=new_property_list)
@@ -171,7 +170,7 @@
in session.setdefault("deleted_categories", {}).setdefault(repository, {}).items()
if cat_name != cat.cat_id
}
- logger.debug("put id: "+cat.cat_id)
+
return 204
def post(self, repository, cat_data):
@@ -202,21 +201,20 @@
property_list.append(
(URIRef(get_property_list()[repository][predicate]["rdflib_class"]), Literal(obj))
)
-
+
cat = Category(
label=cat_data["label"],
description=cat_data["description"],
other_properties=property_list
)
-
-
-
+
+
+
if cat.cat_id not in session.setdefault("modified_categories", {}).setdefault(repository, {}):
session.setdefault("modified_categories", {}).setdefault(repository, {})[cat.cat_id] = str(
cat.cat_graph.serialize(format="turtle"), "utf-8"
)
- logger.debug("post id: "+cat.cat_id)
return cat.cat_id, \
cat.cat_graph.serialize(format='turtle').decode("utf-8"), \
201
@@ -249,13 +247,6 @@
in session["modified_categories"][repository].items()
if cat_name != deleted_cat_id
}
- logger.debug(str(
- {
- cat_name: cat_content for cat_name, cat_content
- in session["modified_categories"][repository].items()
- if cat_name != deleted_cat_id
- }
- ))
# Now we also have to clean up categories that reference the
# deleted category
cat_manager_instance = CategoryManager(
@@ -266,15 +257,11 @@
)
cat_list = cat_manager_instance.list_categories()
# first we edit what was already modified before the deletion
- logger.debug(
- session.setdefault("modified_categories", {}).setdefault(repository, {})
- )
if (
deleted_cat_id in session.setdefault("deleted_categories", {}).setdefault(repository, {})
):
for element in session.setdefault("modified_categories", {}) \
.setdefault(repository, {}):
- logger.debug(str(element))
modified_cat_graph = Graph()
modified_cat_graph.parse(
source=StringIO(
@@ -336,7 +323,6 @@
"utf-8"
)
- logger.debug("delete id: " + deleted_cat_id)
return 204
--- a/src/catedit/tasks.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/tasks.py Wed Apr 15 02:48:22 2015 +0200
@@ -21,15 +21,6 @@
)
if cat_manager_instance.persistence.session_compliant is True:
- logger.debug(
- "Submitting - deleted categories are:"
- + str(
- modified_categories
- ) + " and modified categories are:"
- + str(
- deleted_categories
- )
- )
cat_manager_instance.save_changes(
deleted_cat_dict=deleted_categories,
modified_cat_dict=modified_categories,
--- a/src/catedit/views/categories.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/views/categories.py Wed Apr 15 02:48:22 2015 +0200
@@ -58,18 +58,12 @@
if deleted_changes_id is None and deleted_cat_id is None:
cat_changes_api_instance.delete(repository=repository)
elif deleted_changes_id is not None:
- logger.debug("Changes for category "
- + deleted_changes_id
- + " will be deleted.")
cat_changes_api_instance.delete(
repository=repository,
modified_cat_id=deleted_changes_id
)
# We identify if we want to delete a category
elif deleted_cat_id is not None:
- logger.debug("Category "
- + deleted_cat_id
- + " will be deleted.")
cat_api_instance.delete(
repository=repository,
deleted_cat_id=deleted_cat_id
@@ -141,10 +135,6 @@
cat_api_instance = CategoryAPI()
cat_changes_api_instance = CategoryChangesAPI()
- logger.debug(
- "submit page for " + repository + ", method is " + request.method
- )
-
if deleted_cat_id is None and deleted_changes_id is None:
commit_form = CommitForm(request.form)
@@ -313,7 +303,6 @@
current_cat = Category(graph=cat_rdf_graph)
current_cat_id = current_cat.cat_id
current_cat_properties = current_cat.properties
- logger.debug(current_cat.properties)
serialized_cat_list = cat_api_instance.get(repository)[0]
cat_changes = cat_changes_api_instance.get(repository)[0]
--- a/src/catedit/views/home.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/views/home.py Wed Apr 15 02:48:22 2015 +0200
@@ -43,11 +43,11 @@
Function that handles callback from Github after succesful login
"""
session.permanent = False
+
if session.get("user_code", None) is None:
# That means we got here using github callback
# and not the login form
session["user_code"] = oauth_code
- logger.debug(session["user_code"])
session["user_logged"] = True
session["user_login"] = "auth-error"
@@ -55,14 +55,17 @@
repo: {} for
repo in app.config["PERSISTENCE_CONFIG"]["REPOSITORY_LIST"]
}
+
session["deleted_categories"] = {
repo: {} for repo
in app.config["PERSISTENCE_CONFIG"]["REPOSITORY_LIST"]
}
+
session["tasks"] = {
repo: [] for repo
in app.config["PERSISTENCE_CONFIG"]["REPOSITORY_LIST"]
}
+
try:
session["user_login"] = github.get(
"user",
@@ -73,6 +76,7 @@
"GitHubError trying to get the user login"
)
logger.error(ghe.response.text)
+
try:
repo_list = []
repo_list = github.get("user/repos")
@@ -86,13 +90,13 @@
session["user_can_edit"] = {}
for repo in session["user_repositories"]:
session["user_can_edit"][repo] = True
- logger.debug("User can edit: "+str(session["user_can_edit"]))
except GitHubError as ghe:
logger.error(
"GitHubError trying to get the list of repository for user "
+ session["user_login"]
)
logger.error(ghe.response.text)
+
return redirect(url_for('home.index'))
--- a/src/catedit/views/utils.py Wed Apr 15 01:20:51 2015 +0200
+++ b/src/catedit/views/utils.py Wed Apr 15 02:48:22 2015 +0200
@@ -90,7 +90,7 @@
+ str(page) + "_" + str(per_page)
# Cache key for comments key registry for this repo
registry_key = "comments_"+repository+"_keys"
-
+
if (cache.get(registry_key) is None or cache_key not in cache.get(registry_key)) and cache.get(cache_key) is None:
github_comments_data = []
@@ -194,7 +194,7 @@
"per_page": per_page
}
rv = (thread_dict, pagination)
-
+
# Cache operations
# Setting key for this function
cache.set(cache_key, rv, timeout=3600)
@@ -205,8 +205,7 @@
if cache_key not in cache.get(registry_key):
key_list = cache.get(registry_key)
key_list.append(cache_key)
- logger.debug("list of keys for "+registry_key+" registry: "+str(key_list))
- cache.set(registry_key, key_list)
+ cache.set(registry_key, key_list)
return rv
else:
return cache.get(cache_key)
@@ -272,7 +271,7 @@
+ " - comment_body : " + comment_body
)
logger.error(ghe.response.text)
-
+
registry_key = "comments_"+repository+"_keys"
if cache.get(registry_key) is not None:
for key in cache.get(registry_key):
@@ -297,10 +296,10 @@
cache_key = "get_commits_" \
+ repository + "_" \
+ str(page) + "_" + str(per_page)
-
+
# Cache key for comments key registry for this repo
- registry_key = "categories_"+repository+"_keys"
-
+ registry_key = "categories_"+repository+"_keys"
+
if (cache.get(registry_key) is None or cache_key not in cache.get(registry_key)) and cache.get(cache_key) is None:
commits_data = []
try:
@@ -337,7 +336,7 @@
for commit in commits_data
]
rv = (changeset_list, commits_pagination)
-
+
# Cache operations
# Setting key for this function
cache.set(cache_key, rv, timeout=3600)
@@ -348,8 +347,7 @@
if cache_key not in cache.get(registry_key):
key_list = cache.get(registry_key)
key_list.append(cache_key)
- logger.debug("list of keys for "+registry_key+" registry: "+str(key_list))
- cache.set(registry_key, key_list)
+ cache.set(registry_key, key_list)
return rv
else:
return cache.get(cache_key)
@@ -367,15 +365,15 @@
comment_count: comments count
}
"""
-
+
# Cache key for this function and parameters
cache_key = "get_issues_" \
+ repository + "_" \
+ str(page) + "_" + str(per_page)
-
+
# Cache key for comments key registry for this repo
registry_key = "comments_"+repository+"_keys"
-
+
if (cache.get(registry_key) is None or cache_key not in cache.get(registry_key)) and cache.get(cache_key) is None:
issues_data = []
try:
@@ -411,7 +409,7 @@
for issue in issues_data
]
rv = (discussion_list, discussions_pagination)
-
+
# Cache operations
# Setting key for this function
cache.set(cache_key, rv, timeout=3600)
@@ -422,7 +420,6 @@
if cache_key not in cache.get(registry_key):
key_list = cache.get(registry_key)
key_list.append(cache_key)
- logger.debug("list of keys for "+registry_key+" registry: "+str(key_list))
cache.set(registry_key, key_list)
return rv
else:
@@ -632,7 +629,6 @@
def get_tasks_status(task_ids_list, delete_task_from_session, repository) :
- logger.debug("get_tasks_status : %r " % task_ids_list)
res = { 'states' : {} }
running_tasks_nb = 0
for task_id in task_ids_list: