X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifoldapi%2Fmanifoldproxy.py;h=0f700bf7c3f5cfc14c24144bdba15a6e3a7542f0;hb=3d6c5110a118df0efbd5a3d0de4a0dbd5331b2a5;hp=5a095bfc9f3a03dd1d8debe3c6184841a8d608d1;hpb=6c38e861f92b75716f40ed9d8f15af824d1ec19c;p=myslice.git diff --git a/manifoldapi/manifoldproxy.py b/manifoldapi/manifoldproxy.py index 5a095bfc..0f700bf7 100644 --- a/manifoldapi/manifoldproxy.py +++ b/manifoldapi/manifoldproxy.py @@ -10,9 +10,8 @@ from manifold.core.query import Query from manifold.core.result_value import ResultValue from manifoldapi import ManifoldAPI from manifoldresult import ManifoldException -from manifold.util.log import Log -from unfold.sessioncache import SessionCache +# from unfold.sessioncache import SessionCache from myslice.settings import config, logger @@ -38,14 +37,14 @@ def proxy (request,format): # expecting a POST if request.method != 'POST': logger.error("MANIFOLDPROXY unexpected method {} -- exiting".format(request.method)) - return HttpResponse ({"ret":0}, mimetype="application/json") + return HttpResponse ({"ret":0}, content_type="application/json") # we only support json for now # if needed in the future we should probably cater for # format_in : how is the query encoded in POST # format_out: how to serve the results if format != 'json': logger.error("MANIFOLDPROXY unexpected format {} -- exiting".format(format)) - return HttpResponse ({"ret":0}, mimetype="application/json") + return HttpResponse ({"ret":0}, content_type="application/json") try: # translate incoming POST request into a query object #logger.debug("MANIFOLDPROXY request.POST {}".format(request.POST)) @@ -61,12 +60,15 @@ def proxy (request,format): admin_user, admin_password = config.manifold_admin_user_password() manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password} else: - manifold_api_session_auth = SessionCache().get_auth(request) - if not manifold_api_session_auth: - return HttpResponse (json.dumps({'code':0,'value':[]}), mimetype="application/json") + if 'manifold' in request.session: + manifold_api_session_auth = request.session['manifold']['auth'] + else: + #manifold_api_session_auth = SessionCache().get_auth(request) + #if not manifold_api_session_auth: + return HttpResponse (json.dumps({'code':0,'value':[]}), content_type="application/json") if debug_empty and manifold_query.action.lower()=='get': - return HttpResponse (json.dumps({'code':0,'value':[]}), mimetype="application/json") + return HttpResponse (json.dumps({'code':0,'value':[]}), content_type="application/json") # actually forward manifold_api= ManifoldAPI(auth=manifold_api_session_auth) @@ -101,13 +103,13 @@ def proxy (request,format): json_answer=json.dumps(result) - return HttpResponse (json_answer, mimetype="application/json") + return HttpResponse (json_answer, content_type="application/json") except Exception as e: logger.error("MANIFOLDPROXY {}".format(e)) import traceback logger.error(traceback.format_exc()) - return HttpResponse ({"ret":0}, mimetype="application/json") + return HttpResponse ({"ret":0}, content_type="application/json") #################### # see CSRF_FAILURE_VIEW in settings.py @@ -116,4 +118,4 @@ def proxy (request,format): failure_answer=[ "csrf_failure" ] def csrf_failure(request, reason=""): logger.error("CSRF failure with reason '{}'".format(reason)) - return HttpResponseForbidden (json.dumps (failure_answer), mimetype="application/json") + return HttpResponseForbidden (json.dumps (failure_answer), content_type="application/json")