From 00e925de365deefe83fd1bf17726dce43947dfbd Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 8 Mar 2013 15:54:03 +0100 Subject: [PATCH] scaffold the forwarding of requests to the backend --- engine/manifoldapi.py | 13 +++++++++++++ engine/manifoldproxy.py | 9 +++++++++ engine/manifoldquery.py | 11 +++++++++++ trash/dashboard.py | 4 ++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/engine/manifoldapi.py b/engine/manifoldapi.py index b900855f..21a9ec9c 100644 --- a/engine/manifoldapi.py +++ b/engine/manifoldapi.py @@ -28,3 +28,16 @@ class ManifoldAPI: if debug: print methodName, self.auth, self.url,'->',result return result return func + + # 4amine : xxx + def send_manifold_query (self, manifold_query): + (action,method)= (raw_query.action,raw_query.method) + if action=='get': + return self.Get(method, + # need to fill in the other args here + ) + # xxx... + elif action=='others': + return None + + diff --git a/engine/manifoldproxy.py b/engine/manifoldproxy.py index 52c747ff..109f5934 100644 --- a/engine/manifoldproxy.py +++ b/engine/manifoldproxy.py @@ -9,6 +9,8 @@ import json #from django.core import serializers from django.http import HttpResponse, HttpResponseForbidden +from engine.manifoldquery import ManifoldQuery + # xxx should probably cater for # format_in : how is the query encoded in POST # format_out: how to serve the results @@ -23,6 +25,13 @@ def api (request,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= + # 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 return HttpResponse (json.dumps(answer), mimetype="application/json") diff --git a/engine/manifoldquery.py b/engine/manifoldquery.py index 188a1d45..e48c94d6 100644 --- a/engine/manifoldquery.py +++ b/engine/manifoldquery.py @@ -46,3 +46,14 @@ class ManifoldQuery: sq="{%s}"%sq return """ new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, %(sq)s)"""%locals() + + # 4amine + # xxx + # this should build an object from a dict as received from javascript + # to see an example just look at the server's output + # incoming POST + def fill_from_dict (self, d): + # mandatory... + self.action=d['action'] + self.method=d['method'] + # diff --git a/trash/dashboard.py b/trash/dashboard.py index e7ea8994..0991ea5f 100644 --- a/trash/dashboard.py +++ b/trash/dashboard.py @@ -33,7 +33,7 @@ def dashboard_view (request): main_plugin = SimpleList ( # setting visible attributes first pluginset=pluginset, - title='SimpleList and dataTables', + title='Asynchroneous SimpleList', header='slices list', with_datatables=True, toggled=False, @@ -59,7 +59,7 @@ def dashboard_view (request): # template_env [ 'content_related' ] = related_plugin.render (request) # more general variables expected in the template - template_env [ 'title' ] = 'SimpleList Test View' + template_env [ 'title' ] = 'Test view for a full request cycle' # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request) # so we can sho who is logged -- 2.43.0