From: Loic Baron Date: Fri, 23 Jan 2015 16:14:03 +0000 (+0100) Subject: REST clear cache: simple update to clear Manifold cache X-Git-Tag: myslice-1.3~104^2~1 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d7aa8468317d39746882d6402affbf800de5cf51;p=unfold.git REST clear cache: simple update to clear Manifold cache --- diff --git a/myslice/urls.py b/myslice/urls.py index c815148e..da697cf7 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -92,6 +92,7 @@ urls = [ (r'^create/(?P[^/]+)/(?P[^/]+)?/?$', 'rest.create.dispatch'), (r'^delete/(?P[^/]+)/(?P[^/]+)?/?$', 'rest.delete.dispatch'), (r'^credentials/(?P[^/]+)/?$', 'rest.credentials.dispatch'), + (r'^cache/(?P[^/]+)/?$', 'rest.cache.dispatch'), (r'^initscript/(?P[^/]+)/?$', 'rest.initscript.dispatch'), # # REST monitoring diff --git a/rest/cache.py b/rest/cache.py new file mode 100644 index 00000000..39439469 --- /dev/null +++ b/rest/cache.py @@ -0,0 +1,22 @@ +from django.http import HttpResponse +from portal.actions import clear_user_creds + +from manifoldapi.manifoldapi import execute_query +from manifold.core.query import Query + +import json + +def dispatch(request, action): + + if (action == 'clear') : + query = Query.update('myslice:user').filter_by('user_hrn', '==', '$user_hrn').set({'user_email':str(request.user)}) + try: + res = execute_query(request, query) + except Exception, e: + ret = { "ret" : -1, "error" : "error clearing cache: %s" % e } + return HttpResponse(json.dumps(ret), content_type="application/json") + + ret = { "ret" : 1 } + else: + ret = { "ret" : 0, "error" : "action not supported" } + return HttpResponse(json.dumps(ret), content_type="application/json")