1 # this view is what the javascript talks to when it sends a query
5 # static/js/manifold-async.js
8 # this is for django objects only
9 #from django.core import serializers
10 from django.http import HttpResponse
12 # xxx should probably cater for
13 # format_in : how is the query encoded in POST
14 # format_out: how to serve the results
15 def api (request,format):
17 if request.method != 'POST':
18 print "manifoldproxy.api: unexpected method %s -- exiting"%request.method
20 # we only support json for now
22 print "manifoldproxy.api: unexpected format %s -- exiting"%format
25 # xxx actually ask the backend here
26 hard_wired_answer = [ {'slice_hrn':'a.b.c'}, {'slice_hrn':'ple.inria.foo' } ]
27 answer=hard_wired_answer
28 return HttpResponse (json.dumps(answer), mimetype="application/json")
31 # to enable : see CSRF_FAILURE_VIEW in settings.py
32 # probably we want to elaborate this one a little in real life
33 # at least we can display the reason in the django output (although this turns out disappointing)
34 failure_answer=[ "csrf_failure" ]
35 def csrf_failure(request, reason=""):
36 print "CSRF failure with reason '%s'"%reason
37 return HttpResponseForbidden (json.dump (failure_answer), mimetype="application/json")