[Mpuls-commits] r3246 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 26 19:30:42 CEST 2010


Author: bh
Date: 2010-07-26 19:30:40 +0200 (Mon, 26 Jul 2010)
New Revision: 3246

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/db.py
Log:
* mpulsweb/lib/db.py (PostgresDBInterface): Adapt to new DB
interface of libformed.
Requires libformed revision 189:04cc144d9567


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-07-26 14:00:49 UTC (rev 3245)
+++ base/trunk/ChangeLog	2010-07-26 17:30:40 UTC (rev 3246)
@@ -1,3 +1,9 @@
+2010-07-26  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/db.py (PostgresDBInterface): Adapt to new DB
+	interface of libformed.
+	Requires libformed revision 189:04cc144d9567
+
 2010-07-26  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	Issue871:

Modified: base/trunk/mpulsweb/lib/db.py
===================================================================
--- base/trunk/mpulsweb/lib/db.py	2010-07-26 14:00:49 UTC (rev 3245)
+++ base/trunk/mpulsweb/lib/db.py	2010-07-26 17:30:40 UTC (rev 3246)
@@ -35,6 +35,7 @@
 
 from paste.registry import StackedObjectProxy
 
+from formed.instance.backends.database import DB as FormEdDBInterface
 
 log = logging.getLogger(__name__)
 
@@ -133,25 +134,23 @@
             db.recycleConnection(con, cur)
 
 
-class DBInterface:
+class PostgresDBInterface(FormEdDBInterface):
 
-    def acquireConnection(self):
-        return None
+    def __init__(self):
+        FormEdDBInterface.__init__(self)
+        self.connection = None
 
-    def releaseConnection(self):
-        pass
+    def acquire_cursor(self):
+        if self.connection is None:
+            self.connection = db.getConnection()
+        return self.connection.cursor()
 
-class PostgresDBInterface(DBInterface):
-
-    def acquireCursor(self):
-        conn = db.getConnection()
-        return conn.cursor()
-
-    def releaseCursor(self, cursor):
-        if cursor is not None:
-            conn = cursor.connection
+    def release_cursor(self, cur):
+        if self.transaction_level == 0:
+            db.recycleConnection(self.connection, cur)
+            self.connection = None
         else:
-            conn = None
-        db.recycleConnection(conn, cursor)
+            cur.close()
 
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list