--- a/src/catedit/api.py Tue Nov 25 16:24:37 2014 +0100
+++ b/src/catedit/api.py Wed Nov 26 16:57:48 2014 +0100
@@ -21,19 +21,21 @@
class CategoryAPI(Resource):
# returns category cat_id
@classmethod
- @cache.memoize(timeout=600)
+ @cache.memoize(timeout=3600)
def get(self, cat_id=None):
# load file cat_id
# TODO: load list if cat_id=None
cat_manager_instance = CategoryManager()
if cat_id is not None:
c = cat_manager_instance.load_cat(cat_id)
+ print "get id: "+c.cat_id
return c.cat_graph.serialize(format='turtle')
else:
response=[]
for c in cat_manager_instance.list_cat():
response.append(c.cat_graph.serialize(format='turtle'))
# print response
+ print "get id: None"
return response
# update category cat_id
@@ -56,16 +58,16 @@
["object_type"] == "uriref-category" :
property_object_to_append = app.config["ONTOLOGY_NAMESPACE"] \
+property_object
- print property_object_to_append
+ # print property_object_to_append
new_property_list.append((property_predicate, property_object_to_append))
- print new_property_list
+ # print new_property_list
c = cat_manager_instance.load_cat(cat_id)
c.edit_category(new_description=args["description"],
new_label=args["label"],
new_other_properties=new_property_list)
cat_manager_instance.save_cat(c, message=args["commit_message"])
- cache.delete_memoized(CategoryAPI.get,cat_id)
- cache.delete_memoized(CategoryAPI.get,None)
+ print "put id: "+c.cat_id
+ cache.clear()
return c.cat_graph.serialize(format='turtle'), 200
# Maybe not send the whole cat back, see if it's worth it
@@ -73,28 +75,37 @@
def post(self):
args = cat_parser.parse_args()
property_list = []
- print args["property_predicate"]
- print args["property_object"]
+ #print args["property_predicate"]
+ #print args["property_object"]
for property_predicate, property_object in zip(
request.form.getlist('property_predicate'),
request.form.getlist('property_object')):
if property_object:
- property_list.append((property_predicate, property_object))
+ if app.config["PROPERTY_LIST"] \
+ [property_predicate] \
+ ["object_type"]=="uriref-category":
+ property_list.append((property_predicate,
+ app.config["ONTOLOGY_NAMESPACE"]
+ +property_object))
+ else:
+ property_list.append((property_predicate,
+ property_object))
+ # print property_list
c = Category(label=args["label"],
description=args["description"],
other_properties=property_list)
cat_manager_instance = CategoryManager()
cat_manager_instance.save_cat(c, message=args["commit_message"])
- cache.delete_memoized("get",cat_id)
- cache.delete_memoized("get",None)
+ print "post id: "+c.cat_id
+ cache.clear()
return c.cat_graph.serialize(format='turtle'), 201
@classmethod
def delete(self, cat_id):
cat_manager_instance = CategoryManager()
cat_manager_instance.delete_cat(cat_id)
- cache.delete_memoized(CategoryAPI.get,cat_id)
- cache.delete_memoized(CategoryAPI.get,None)
+ print "delete id: "+cat_id
+ cache.clear()
return 204
api.add_resource(CategoryAPI,
--- a/src/catedit/views.py Tue Nov 25 16:24:37 2014 +0100
+++ b/src/catedit/views.py Wed Nov 26 16:57:48 2014 +0100
@@ -147,7 +147,7 @@
session["user_can_edit"] = True
if not any (repo["name"] == app.config["REPOSITORY_NAME"] for repo in repoList):
session["user_can_edit"] = False
- print session["user_can_edit"]
+ # print session["user_can_edit"]
except GitHubError:
# print "error getting repos!"
pass