debug & renamings
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 11 Mar 2013 13:51:27 +0000 (14:51 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 11 Mar 2013 13:51:27 +0000 (14:51 +0100)
engine/manifoldapi.py
engine/manifoldproxy.py
engine/pluginset.py

index ebb6b4a..111241c 100644 (file)
@@ -25,7 +25,14 @@ class ManifoldAPI:
   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
 
index 20e9592..d5a4ab0 100644 (file)
@@ -6,6 +6,10 @@ from django.http import HttpResponse, HttpResponseForbidden
 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
@@ -34,6 +38,9 @@ with the query passed using POST"""
     # 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")
 
index 0a0e291..be8c9ce 100644 (file)
@@ -45,12 +45,12 @@ class PluginSet:
     # 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()