Commit 6c432605 authored by Florent Guillaume's avatar Florent Guillaume

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.
parent b3acf391
......@@ -142,16 +142,11 @@ class MountedObject(SimpleItem):
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
......
......@@ -176,7 +176,22 @@ class MountingTests(unittest.TestCase):
'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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment