need proper logged_user and close method to be usable as native source connection wrapper stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 09 Jun 2009 11:32:41 +0200
branchstable
changeset 2067 668cc93f8578
parent 2066 2c4bf4ee88a2
child 2068 3d1961426bed
need proper logged_user and close method to be usable as native source connection wrapper
server/sources/extlite.py
--- a/server/sources/extlite.py	Tue Jun 09 11:31:57 2009 +0200
+++ b/server/sources/extlite.py	Tue Jun 09 11:32:41 2009 +0200
@@ -20,6 +20,17 @@
         self.source = source
         self._cnx = None
 
+    @property
+    def logged_user(self):
+        if self._cnx is None:
+            self._cnx = self.source._sqlcnx
+        return self._cnx.logged_user
+
+    def cursor(self):
+        if self._cnx is None:
+            self._cnx = self.source._sqlcnx
+        return self._cnx.cursor()
+
     def commit(self):
         if self._cnx is not None:
             self._cnx.commit()
@@ -28,10 +39,10 @@
         if self._cnx is not None:
             self._cnx.rollback()
 
-    def cursor(self):
-        if self._cnx is None:
-            self._cnx = self.source._sqlcnx
-        return self._cnx.cursor()
+    def close(self):
+        if self._cnx is not None:
+            self._cnx.close()
+            self._cnx = None
 
 
 class SQLiteAbstractSource(AbstractSource):