[Zope-Checkins]
SVN: Zope/branches/2.9/lib/python/Products/ZODBMountPoint/
Cleaner fix (end result is the same as previous patch though).
Florent Guillaume
fg at nuxeo.com
Mon Jan 9 09:47:57 EST 2006
Log message for revision 41241:
Cleaner fix (end result is the same as previous patch though).
See http://mail.zope.org/pipermail/zodb-dev/2005-December/009662.html
for a fuller problem description.
Unit test included.
Changed:
U Zope/branches/2.9/lib/python/Products/ZODBMountPoint/MountedObject.py
U Zope/branches/2.9/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
-=-
Modified: Zope/branches/2.9/lib/python/Products/ZODBMountPoint/MountedObject.py
===================================================================
--- Zope/branches/2.9/lib/python/Products/ZODBMountPoint/MountedObject.py 2006-01-09 14:34:15 UTC (rev 41240)
+++ Zope/branches/2.9/lib/python/Products/ZODBMountPoint/MountedObject.py 2006-01-09 14:47:56 UTC (rev 41241)
@@ -142,16 +142,11 @@
self.id = id
def _getMountedConnection(self, anyjar):
- db_name = self._getDBName()
- try:
- conn = anyjar.get_connection(db_name)
- except KeyError:
- conn = self._getDB().open()
- # FIXME: The following should be done by ZODB's multidatabase
- # code, it does it correctly for get_connection().
- anyjar.connections.update(conn.connections)
- conn.connections = anyjar.connections
- return conn
+ # This creates the DB if it doesn't exist yet and adds it
+ # to the multidatabase
+ self._getDB()
+ # Return a new or existing connection linked to the multidatabase set
+ return anyjar.get_connection(self._getDBName())
def mount_error_(self):
return self._v_connect_error
Modified: Zope/branches/2.9/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
===================================================================
--- Zope/branches/2.9/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2006-01-09 14:34:15 UTC (rev 41240)
+++ Zope/branches/2.9/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2006-01-09 14:47:56 UTC (rev 41241)
@@ -176,8 +176,23 @@
'name': 'test_mount2.fs',
'exists': 1}]
self.assertEqual(expected, status)
-
+ def test_close(self):
+ app = self.app
+ app.mount1.a1 = '1'
+ app.mount2.a2 = '2'
+ app.a3 = '3'
+ conn1 = app.mount1._p_jar
+ conn2 = app.mount2._p_jar
+ transaction.abort()
+ # Close the main connection
+ app._p_jar.close()
+ self.assertEqual(app._p_jar._opened, None)
+ # Check that secondary connections have been closed too
+ self.assertEqual(conn1._opened, None)
+ self.assertEqual(conn2._opened, None)
+
+
def test_suite():
return unittest.makeSuite(MountingTests, 'test')
More information about the Zope-Checkins
mailing list