[Zope-CVS] CVS: Products/DBTab - CHANGES.txt:1.2 DBTab.py:1.7 custom_zodb.py:1.2
Shane Hathaway
shane@zope.com
Wed, 18 Dec 2002 17:54:43 -0500
Update of /cvs-repository/Products/DBTab
In directory cvs.zope.org:/tmp/cvs-serv20611
Modified Files:
CHANGES.txt DBTab.py custom_zodb.py
Log Message:
Arranged for Zope to properly close open database connections on clean
shutdown.
=== Products/DBTab/CHANGES.txt 1.1 => 1.2 ===
--- Products/DBTab/CHANGES.txt:1.1 Wed Dec 18 15:49:11 2002
+++ Products/DBTab/CHANGES.txt Wed Dec 18 17:54:41 2002
@@ -14,4 +14,6 @@
Activity you will be redirected to the manage workspace of the
folder.
+- Arranged for Zope to properly close open database connections on
+ clean shutdown.
=== Products/DBTab/DBTab.py 1.6 => 1.7 ===
--- Products/DBTab/DBTab.py:1.6 Wed Dec 18 15:49:11 2002
+++ Products/DBTab/DBTab.py Wed Dec 18 17:54:41 2002
@@ -23,6 +23,7 @@
builtin = sys.modules['__builtin__']
from ZODB.ActivityMonitor import ActivityMonitor
+import Globals
from Exceptions import DBTabConfigurationError
from StorageTypes import storage_types, asBoolean
@@ -292,7 +293,7 @@
% mount_path)
- def getDatabase(self, mount_path=None, name=None):
+ def getDatabase(self, mount_path=None, name=None, is_root=0):
"""Returns an opened database. Requires either mount_path or name.
"""
self.startup()
@@ -312,7 +313,7 @@
# by another thread before the lock was acquired.
db = self.opened.get(name)
if db is None:
- db = self._createDatabase(name)
+ db = self._createDatabase(name, is_root)
finally:
self.lock.release()
return db
@@ -328,10 +329,14 @@
return self.db_factories[name]
- def _createDatabase(self, name):
+ def _createDatabase(self, name, is_root):
factory = self.db_factories[name]
db = factory.create()
self.opened[name] = db
+ if not is_root:
+ Globals.opened.append(db)
+ # If it is the root database, Zope will add the database to
+ # Globals.opened. A database should not be listed twice.
return db
def _parseParams(self, config, section, vars=None):
=== Products/DBTab/custom_zodb.py 1.1.1.1 => 1.2 ===
--- Products/DBTab/custom_zodb.py:1.1.1.1 Tue Oct 15 13:49:20 2002
+++ Products/DBTab/custom_zodb.py Wed Dec 18 17:54:41 2002
@@ -18,5 +18,5 @@
from Products.DBTab.MainConfiguration import configuration
-DB = configuration.getDatabase('/')
+DB = configuration.getDatabase('/', is_root=1)