From 129d3dac66455410b60162594d8b3387ff4e0203 Mon Sep 17 00:00:00 2001 From: Mohamed Larabi Date: Fri, 8 Mar 2013 18:00:43 +0100 Subject: [PATCH] Query trip: bridge the gap between FE nad BE --- engine/manifoldapi.py | 6 ++---- engine/manifoldproxy.py | 17 ++++++++--------- engine/manifoldquery.py | 9 ++++++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/engine/manifoldapi.py b/engine/manifoldapi.py index 21a9ec9c..c8c3e666 100644 --- a/engine/manifoldapi.py +++ b/engine/manifoldapi.py @@ -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 diff --git a/engine/manifoldproxy.py b/engine/manifoldproxy.py index 109f5934..9f119dae 100644 --- a/engine/manifoldproxy.py +++ b/engine/manifoldproxy.py @@ -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") #################### diff --git a/engine/manifoldquery.py b/engine/manifoldquery.py index e48c94d6..47b261f4 100644 --- a/engine/manifoldquery.py +++ b/engine/manifoldquery.py @@ -54,6 +54,9 @@ class ManifoldQuery: # incoming POST 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'] -- 2.43.0