# 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
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
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")
####################
# 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']