Query trip: bridge the gap between FE nad BE
authorMohamed Larabi <mohamed.larabi@inria.fr>
Fri, 8 Mar 2013 17:00:43 +0000 (18:00 +0100)
committerMohamed Larabi <mohamed.larabi@inria.fr>
Fri, 8 Mar 2013 17:00:43 +0000 (18:00 +0100)
engine/manifoldapi.py
engine/manifoldproxy.py
engine/manifoldquery.py

index 21a9ec9..c8c3e66 100644 (file)
@@ -31,11 +31,9 @@ class ManifoldAPI:
 
   # 4amine : xxx
   def send_manifold_query (self, manifold_query):
-    (action,method)= (raw_query.action,raw_query.method)
+    (action,method)= (manifold_query.action,manifold_query.method)
     if action=='get':
-      return self.Get(method,
-                      # need to fill in the other args here
-                      )
+      return self.proxy.Get(self.auth, method, manifold_query.filters, {}, manifold_query.fields)
     # xxx...
     elif action=='others':
       return None
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")
 
 #################### 
index e48c94d..47b261f 100644 (file)
@@ -54,6 +54,9 @@ class ManifoldQuery:
     # incoming POST <QueryDict: {u'query[method]': [u'slice'], u'query[fields][]': [u'slice_hrn'], u'query[ts]': [u'latest'], u'query[action]': [u'get']}>
     def fill_from_dict (self, d):
         # mandatory...
-        self.action=d['action']
-        self.method=d['method']
-        # 
+        self.action=d['query[action]']
+        self.method=d['query[method]']
+        self.fields=[d['query[fields][]']]
+        self.timestamp=d['query[ts]'] 
+        #self.filters=d['filters']
+        #self.params=d['params']