Query trip: bridge the gap between FE nad BE
[unfold.git] / engine / manifoldproxy.py
index 109f593..9f119da 100644 (file)
@@ -10,6 +10,7 @@ import json
 from django.http import HttpResponse, HttpResponseForbidden
 
 from engine.manifoldquery import ManifoldQuery
+from engine.manifoldapi import ManifoldAPI
 
 # xxx should probably cater for
 # format_in : how is the query encoded in POST
@@ -23,17 +24,15 @@ def api (request,format):
     if format != 'json':
         print "manifoldproxy.api: unexpected format %s -- exiting"%format
         return
-
     # xxx actually ask the backend here
-    # 4amine
-    # manifold_query = ManifoldQuery()
-    # manifold_query.fill_from_dict(request.POST)
-    # locate the api and/or the auth
-    # api=
+    manifold_query = ManifoldQuery()
+    manifold_query.fill_from_dict(request.POST)
+    manifold_api_session_auth = request.session['manifold']['auth']
+    manifold_api= ManifoldAPI(auth=manifold_api_session_auth)
     # forward
-    # answer=api.send_manifold_query (manifold_query)
-    hard_wired_answer = [ {'slice_hrn':'a.b.c'}, {'slice_hrn':'ple.inria.foo' } ]
-    answer=hard_wired_answer
+    answer=manifold_api.send_manifold_query (manifold_query)
+    #hard_wired_answer = [ {'slice_hrn':'a.b.c'}, {'slice_hrn':'ple.inria.foo' } ]
+    #answer=hard_wired_answer
     return HttpResponse (json.dumps(answer), mimetype="application/json")
 
 ####################