Auto Validation of PLE enabled users
[unfold.git] / manifoldapi / manifoldproxy.py
index c16ffde..433a854 100644 (file)
@@ -40,7 +40,7 @@ with the query passed using POST"""
     # format_out: how to serve the results
     if format != 'json':
         print "manifoldproxy.proxy: unexpected format %s -- exiting"%format
-        return
+        return HttpResponse ({"ret":0}, mimetype="application/json")
     try:
         # translate incoming POST request into a query object
         if debug: print 'manifoldproxy.proxy: request.POST',request.POST
@@ -55,9 +55,12 @@ with the query passed using POST"""
             admin_user, admin_password = ConfigEngine().manifold_admin_user_password()
             manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password}
         else:
-            print request.session['manifold']
-            manifold_api_session_auth = request.session['manifold']['auth']
-
+            if 'manifold' in request.session:
+                manifold_api_session_auth = request.session['manifold']['auth']
+            else:
+                json_answer=json.dumps({'code':0,'value':[]})
+                return HttpResponse (json_answer, mimetype="application/json")
+                
         if debug_empty and manifold_query.action.lower()=='get':
             json_answer=json.dumps({'code':0,'value':[]})
             print "By-passing : debug_empty & 'get' request : returning a fake empty list"
@@ -84,6 +87,7 @@ with the query passed using POST"""
         print "** PROXY ERROR **",e
         import traceback
         traceback.print_exc()
+        return HttpResponse ({"ret":0}, mimetype="application/json")
 
 #################### 
 # see CSRF_FAILURE_VIEW in settings.py