[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/ZODBMountPoint/
Fixed mounting problem described in
Florent Guillaume
fg at nuxeo.com
Mon Jan 9 10:07:56 EST 2006
Log message for revision 41242:
Fixed mounting problem described in
http://mail.zope.org/pipermail/zodb-dev/2005-December/009662.html
Basic symptom was lots of conflict in sessions.
Unit test included.
Changed:
U Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py
U Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
-=-
Modified: Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py
===================================================================
--- Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py 2006-01-09 14:47:56 UTC (rev 41241)
+++ Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py 2006-01-09 15:07:55 UTC (rev 41242)
@@ -142,12 +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()
- 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/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
===================================================================
--- Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2006-01-09 14:47:56 UTC (rev 41241)
+++ Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2006-01-09 15:07:55 UTC (rev 41242)
@@ -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