Commit 50499441 authored by Florent Guillaume's avatar Florent Guillaume

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.
parent 4b6ebc45
......@@ -142,12 +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()
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
......
......@@ -177,6 +177,21 @@ class MountingTests(unittest.TestCase):
'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