def __getattr__(self, methodName):
def func(*args, **kwds):
result=getattr(self.proxy, methodName)(self.auth, *args, **kwds)
- if debug: print '===> backend call',methodName, self.auth, self.url,'->',result
+ ### debug
+ if debug:
+ print '===> backend call',methodName, self.auth, self.url,'->',
+ if not result: print "no/empty result"
+ elif isinstance (result,str): print "result is '%s'"%result
+ elif isinstance (result,list): print "result is a %d-elts list"%len(result)
+ else: print "dont know how to display result"
+ ###
return result
return func
from engine.manifoldquery import ManifoldQuery
from engine.manifoldapi import ManifoldAPI
+# add artificial delay in s
+debug_spin=0
+#debug_spin=1
+
# this view is what the javascript talks to when it sends a query
# see also
# myslice/urls.py
# actually forward
manifold_api= ManifoldAPI(auth=manifold_api_session_auth)
answer=manifold_api.send_manifold_query (manifold_query)
+ if debug_spin:
+ import time
+ time.sleep(debug_spin)
# return json-encoded answer
return HttpResponse (json.dumps(answer), mimetype="application/json")
# return the javascript that triggers all the queries
def exec_queue_asynchroneously (self):
js = ""
- js += "var manifold_query_array = new Array();\n"
+ js += "var async_queries = new Array();\n"
for (query,domid) in self._queue:
qjson=query.to_json()
id="'%s'"%domid if domid else 'undefined'
- js += "manifold_query_array.push({'query':%(qjson)s, 'id':%(id)s});\n"%locals()
- js += "onFunctionAvailable('manifold_async_exec', function() {manifold_async_exec(manifold_query_array);}, this, true);"
+ js += "async_queries.push({'query':%(qjson)s, 'id':%(id)s});\n"%locals()
+ js += "onFunctionAvailable('manifold_async_exec', function() {manifold_async_exec(async_queries);}, this, true);"
self.reset_queue()
# run only once the document is ready
js = "$(document).ready(function(){%(js)s})"%locals()