debugging tweaks
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Sat, 01 Aug 2009 01:19:26 +0200
changeset 2619 535bc210f799
parent 2618 ff9b0d5bd884
child 2620 de68f84b8f54
debugging tweaks
server/sources/extlite.py
server/sources/native.py
--- a/server/sources/extlite.py	Sat Aug 01 01:16:19 2009 +0200
+++ b/server/sources/extlite.py	Sat Aug 01 01:19:26 2009 +0200
@@ -30,19 +30,26 @@
     def cursor(self):
         if self._cnx is None:
             self._cnx = self.source._sqlcnx
+            if server.DEBUG & server.DBG_SQL:
+                print 'sql cnx open', self._cnx
         return self._cnx.cursor()
 
     def commit(self):
         if self._cnx is not None:
-            self._cnx.commit()
+            if server.DEBUG & server.DBG_SQL:
+                print 'sql cnx commit', self._cnx
 
     def rollback(self):
         if self._cnx is not None:
+            if server.DEBUG & server.DBG_SQL:
+                print 'sql cnx rollback', self._cnx
             self._cnx.rollback()
 
     def close(self):
         if self._cnx is not None:
             self._cnx.close()
+            if server.DEBUG & server.DBG_SQL:
+                print 'sql cnx close', self._cnx
             self._cnx = None
 
 
@@ -184,11 +191,11 @@
         if self._need_sql_create:
             return []
         sql, query_args = self.rqlsqlgen.generate(union, args)
-        if server.DEBUG:
-            print self.uri, 'SOURCE RQL', union.as_string()
+        if server.DEBUG & server.DBG_RQL:
+            print 'RQL FOR %s SOURCE:' % (self.uri, union.as_string())
         args = self.sqladapter.merge_args(args, query_args)
         res = self.sqladapter.process_result(self.doexec(session, sql, args))
-        if server.DEBUG:
+        if server.DEBUG & (server.DBG_SQL | server.DBG_RQL):
             print '------>', res
         return res
 
--- a/server/sources/native.py	Sat Aug 01 01:16:19 2009 +0200
+++ b/server/sources/native.py	Sat Aug 01 01:19:26 2009 +0200
@@ -309,9 +309,8 @@
             print 'RQL FOR NATIVE SOURCE %s: %s' % (self.uri, union.as_string())
             if varmap:
                 print 'using varmap', varmap
-            if args:
+            if server.DEBUG & server.DBG_MORE:
                 print 'args', args
-            if server.DEBUG & server.DBG_MORE:
                 print 'cache key', cachekey
                 print 'solutions', ','.join(str(s.solutions) for s in union.children)
         # remember number of actually selected term (sql generation may append some)
@@ -438,7 +437,7 @@
         """
         cursor = session.pool[self.uri]
         if server.DEBUG & server.DBG_SQL:
-            print 'exec', query, args, session.pool.connection(self.uri)._cnx
+            print 'exec', query, args
         try:
             # str(query) to avoid error if it's an unicode string
             cursor.execute(str(query), args)