[Zope-Checkins] CVS: Products/DCOracle2 - DA.py:1.8.2.1 SP.py:1.12.2.1

Chris Withers cvs-admin at zope.org
Tue Nov 4 16:48:16 EST 2003


Update of /cvs-repository/Products/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv22843

Modified Files:
      Tag: chrisw_fixconnectionleak_branch
	DA.py SP.py 
Log Message:
First pass at Thread Pool connection model.
Also better handling for errors in DB.query method.


=== Products/DCOracle2/DA.py 1.8 => 1.8.2.1 ===
--- Products/DCOracle2/DA.py:1.8	Mon Nov  3 09:15:27 2003
+++ Products/DCOracle2/DA.py	Tue Nov  4 16:47:45 2003
@@ -135,6 +135,9 @@
 
     def factory(self): return DB
 
+    def table_info(self):
+        return self._v_database_connection.table_info()
+
 class Procedure(SP.Procedure):
     " "
     id='ZOracleStoredProcedure'


=== Products/DCOracle2/SP.py 1.12 => 1.12.2.1 ===
--- Products/DCOracle2/SP.py:1.12	Sat Dec 21 15:29:06 2002
+++ Products/DCOracle2/SP.py	Tue Nov  4 16:47:45 2003
@@ -90,11 +90,11 @@
 import sys
 from Globals import HTMLFile
 from OFS.SimpleItem import SimpleItem
-from Shared.DC.ZRDB.TM import Surrogate
 from string import split
 from AccessControl import getSecurityManager
 import DCOracle2
 from db import LobLocator, DB
+from Products.ZOracleDA.connections import CTM
 
 myname = split(__name__,".")[1]
 if myname == "ZOracleDA":
@@ -102,62 +102,7 @@
 else:
     dbstring = myname
 
-class VTM:
-    """Mix-in class that provides transaction management support
-
-    A sub class should call self._register() whenever it performs
-    any transaction-dependent operations (e.g. sql statements).
-
-    The sub class will need to override _finish, to finalize work,
-    _abort, to roll-back work, and perhaps _begin, if any work is needed
-    at the start of a transaction.
-
-    *** This code copied out from Shared/DC/ZRDB/TM to make _registered
-    *** and _finalize volatile variable names
-    """
-
-    _registered=None
-
-    def _begin(self): pass
-
-    def _register(self):
-        if not self._registered:
-            try:
-                get_transaction().register(Surrogate(self))
-                self._begin()
-                self._v_registered = 1
-                self._v_finalize = 0
-            except:
-                import sys
-                print sys.exc_info()
-
-    def tpc_begin(self, *ignored): pass
-    commit=tpc_begin
-
-    def _finish(self):
-        self.db.commit()
-
-    def _abort(self):
-        self.db.rollback()
-
-    def tpc_vote(self, *ignored):
-        self._v_finalize = 1
-
-    def tpc_finish(self, *ignored):
-
-        if self._v_finalize:
-            try: self._finish()
-            finally: self._v_registered=0
-
-    def abort(self, *ignored):
-        try: self._abort()
-        finally: self._v_registered=0
-
-    tpc_abort = abort
-
-
-
-class Procedure(SimpleItem, VTM):
+class Procedure(SimpleItem, CTM):
 
     manage_options=(
         {'label': 'Edit', 'action':'manage_procview'},
@@ -186,12 +131,12 @@
         self.procname = procname
         self.acquire = acquire
         self._v_proc = None
-        self._v_db = None
 
     
     def _connect(self):
-        db = self._v_db = getattr(self,self.connection)() # Get connection
-        c = db.cursor                          # Get cursor
+
+        db = self.getDB()
+        c = db.cursor()                          # Get cursor
         self._errors = 0
         if self.procname:
             try:
@@ -202,12 +147,6 @@
                 if self._errors > 3: raise
                 
 
-    def _finish(self, *ignored):
-        self._v_db.db.commit()
-
-    def _abort(self, *ignored):
-        self._v_db.db.rollback()
-
     def description(self):
         if getattr(self,"_v_proc",None) is None: self._connect()
         return self._v_proc.__doc__
@@ -220,7 +159,7 @@
 
     def ZSPListPackage(self, package):
 
-        db = self._v_db.db
+        db = self.getDB()
 
         cd = db.collapsedesc(db.describe(package))
 
@@ -239,9 +178,9 @@
 
         results = []
 
-        if getattr(self,"_v_db",None) is None: self._connect()
+        if getattr(self,"_v_proc",None) is None: self._connect()
 
-        objs = self._v_db.db.objects()
+        objs = self.getDB().objects()
 
         for (name, type) in objs:
             if type in ('PROCEDURE', 'FUNCTION'):




More information about the Zope-Checkins mailing list