a first stab at manifoldproxy
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 8 Mar 2013 11:05:34 +0000 (12:05 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 8 Mar 2013 11:05:34 +0000 (12:05 +0100)
engine/manifoldproxy.py [new file with mode: 0644]
myslice/urls.py

diff --git a/engine/manifoldproxy.py b/engine/manifoldproxy.py
new file mode 100644 (file)
index 0000000..0eac779
--- /dev/null
@@ -0,0 +1,26 @@
+# this view is what the javascript talks to when it sends a query
+# see also
+# myslice/urls.py
+# as well as 
+# static/js/manifold-async.js
+
+from django.core import serializers
+from django.http import HttpResponse
+
+# xxx should probably cater for
+# format_in : how is the query encoded in POST
+# format_out: how to serve the results
+def api (request,format):
+    # expecting a POST
+    if request.method != 'POST':
+        print "manifoldproxy.api: unexpected method %s -- exiting"%request.method
+        return 
+    # we only support json for now
+    if format != 'json':
+        print "manifoldproxy.api: unexpected format %s -- exiting"%format
+        return
+
+    # xxx actually ask the backend here
+    hard_wired_answer = {'a':'some string','b':123}
+    return HttpResponse (serializers.serialize("json",hard_wired_answer),
+                         mimetype="application/json")
index 5a8f3a5..b5389a1 100644 (file)
@@ -18,19 +18,30 @@ urlpatterns = patterns(
     # Examples:
     # url(r'^$', 'myslice.views.home', name='home'),
     # url(r'^myslice/', include('myslice.foo.urls')),
-
     # Uncomment the admin/doc line below to enable admin documentation:
     # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
     # Uncomment the next line to enable the admin:
     # url(r'^admin/', include(admin.site.urls)),
+    #
+    # default / view
+    #
     (r'^/?$', default_view),
+    #
+    # login / logout
+    #
     (r'^login-ok/?$', after_login_view),
     # seems to be what login_required uses to redirect ...
     (r'^accounts/login/$', 'auth.views.login_user'),
     (r'^login/?$', 'auth.views.login_user'),
     (r'^logout/?$', 'auth.views.logout_user'),
     (r'^logout/confirm/?$', 'auth.views.do_logout_user'),
+    #
+    # the manifold proxy
+    #
+    (r'^manifold/api/(?P<format>\w+)/?$', 'engine.manifoldproxy.api'),
+    #
+    # various trash views
+    #
     (r'^slice/?$', 'trash.sampleviews.slice_view'),
     (r'^slice/(?P<name>[\w\.]+)/?$', 'trash.sampleviews.slice_view'),
     (r'^tab/?$', 'trash.sampleviews.tab_view'),