server/sources/__init__.py
changeset 2625 d6012db7b93e
parent 2596 d02eed70937f
child 2627 d710278e0c1c
--- a/server/sources/__init__.py	Sat Aug 01 01:24:42 2009 +0200
+++ b/server/sources/__init__.py	Sat Aug 01 16:13:40 2009 +0200
@@ -11,11 +11,32 @@
 from datetime import datetime, timedelta
 from logging import getLogger
 
-from cubicweb import set_log_methods
+from cubicweb import set_log_methods, server
 from cubicweb.schema import VIRTUAL_RTYPES
 from cubicweb.server.sqlutils import SQL_PREFIX
 
 
+def dbg_st_search(uri, union, varmap, args, cachekey=None, prefix='rql for'):
+    if server.DEBUG & server.DBG_RQL:
+        print '%s %s source: %s' % (prefix, uri, union.as_string())
+        if varmap:
+            print '  using varmap', varmap
+        if server.DEBUG & server.DBG_MORE:
+            print '  args', args
+            print '  cache key', cachekey
+            print '  solutions', ','.join(str(s.solutions)
+                                          for s in union.children)
+    # return true so it can be used as assertion (and so be killed by python -O)
+    return True
+
+def dbg_results(results):
+    if server.DEBUG & server.DBG_RQL:
+        if len(results) > 10:
+            print '  -->', results[:10], '...', len(results)
+        else:
+            print '  -->', results
+    # return true so it can be used as assertion (and so be killed by python -O)
+    return True
 
 class TimedCache(dict):
     def __init__(self, ttlm, ttls=0):