[Zope-Checkins] CVS: Products/DCOracle2 - DABase.py:1.7.2.1

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


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

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


=== Products/DCOracle2/DABase.py 1.7 => 1.7.2.1 ===
--- Products/DCOracle2/DABase.py:1.7	Mon Nov  3 09:08:25 2003
+++ Products/DCOracle2/DABase.py	Tue Nov  4 16:46:58 2003
@@ -92,6 +92,7 @@
 from ImageFile import ImageFile
 from ExtensionClass import Base
 import Acquisition
+from Products.ZOracleDA import connections
 
 class Connection(Shared.DC.ZRDB.Connection.Connection):
     _isAnSQLConnection=1
@@ -101,11 +102,55 @@
         {'label': 'Debug', 'action':'manage_trace'},
         )
 
+    manage_main=HTMLFile('dtml/manage_main',globals())
     manage_browse=HTMLFile('dtml/browse',globals())
     manage_trace=HTMLFile('dtml/trace',globals())
 
     info=None
+
+    def connectionInfo(self):
+        result = {}
+        result['connections'] = connections.countConnections(
+                                    self.connection_string
+                                    )
+        result['available'] = len(connections.pool.get(
+                                    self.connection_string,
+                                    []
+                                    ))
+        result['assigned'] = result['connections'] - result['available']
+
+        return result
+
+    def manage_close_connection(self,REQUEST):
+        """Close all connections for our connection string"""
+        # do the normal stuff
+        Shared.DC.ZRDB.Connection.Connection.manage_close_connection(
+            self,REQUEST
+            )
         
+        # empty the pool for our connection string
+        connections.close(self.connection_string)
+
+
+        return self.manage_main(self, REQUEST)
+    
+    def edit(self, title, connection_string, check=1):
+        # release our connection if we have one
+        DB = getattr(self,'_v_database_connection',None)
+        if DB:
+            DB.close()
+            
+        # close connections for current string
+        connections.close(self.connection_string)
+
+        # call original edit
+        Shared.DC.ZRDB.Connection.Connection.edit(
+            self,
+            title,
+            connection_string,
+            check
+            )
+    
     def tpValues(self):
         r=[]
         if hasattr(self,'_v_database_connection'):
@@ -132,8 +177,7 @@
 
     def ZDCO2VERSION(self, REQUEST=None):
         """Print Oracle Version Table"""
-        import DCOracle2
-        return self._v_database_connection.db.Version().items()
+        return self._v_database_connection.getDB().Version().items()
 
 class Browser(Base):
     def __getattr__(self, name):




More information about the Zope-Checkins mailing list