From 2757273117a830a2ec078139acdfb996ed8aec78 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 8 Mar 2013 12:05:34 +0100 Subject: [PATCH] a first stab at manifoldproxy --- engine/manifoldproxy.py | 26 ++++++++++++++++++++++++++ myslice/urls.py | 15 +++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 engine/manifoldproxy.py diff --git a/engine/manifoldproxy.py b/engine/manifoldproxy.py new file mode 100644 index 00000000..0eac7797 --- /dev/null +++ b/engine/manifoldproxy.py @@ -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") diff --git a/myslice/urls.py b/myslice/urls.py index 5a8f3a5f..b5389a1e 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -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\w+)/?$', 'engine.manifoldproxy.api'), + # + # various trash views + # (r'^slice/?$', 'trash.sampleviews.slice_view'), (r'^slice/(?P[\w\.]+)/?$', 'trash.sampleviews.slice_view'), (r'^tab/?$', 'trash.sampleviews.tab_view'), -- 2.43.0