[Zodb-checkins] SVN: ZODB/branches/3.4/src/ZODB/ Fixed a bug in
commits with savepoints and changes since savepoints.
Jim Fulton
jim at zope.com
Sat Apr 23 23:33:29 EDT 2005
Log message for revision 30131:
Fixed a bug in commits with savepoints and changes since savepoints.
Once we start using savepoints, we need to make sure that all data are
committed through the savepoints. Otherwise, things can get committed
in the wrong order, leading to conflicts.
Changed:
U ZODB/branches/3.4/src/ZODB/Connection.py
U ZODB/branches/3.4/src/ZODB/tests/testConnectionSavepoint.py
-=-
Modified: ZODB/branches/3.4/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.4/src/ZODB/Connection.py 2005-04-24 03:02:00 UTC (rev 30130)
+++ ZODB/branches/3.4/src/ZODB/Connection.py 2005-04-24 03:33:29 UTC (rev 30131)
@@ -63,7 +63,6 @@
_storage = _normal_storage = _savepoint_storage = None
- _tmp = None
_code_timestamp = 0
##########################################################################
@@ -437,9 +436,17 @@
"""Commit changes to an object"""
if self._savepoint_storage is not None:
+
+ # We first checkpoint the current changes to the savepoint
+ self.savepoint()
+
+ # then commit all of the savepoint changes at once
self._commit_savepoint(transaction)
- self._commit(transaction)
+ # No need to call _commit since savepoint did.
+
+ else:
+ self._commit(transaction)
def _commit(self, transaction):
"""Commit changes to an object"""
Modified: ZODB/branches/3.4/src/ZODB/tests/testConnectionSavepoint.py
===================================================================
--- ZODB/branches/3.4/src/ZODB/tests/testConnectionSavepoint.py 2005-04-24 03:02:00 UTC (rev 30130)
+++ ZODB/branches/3.4/src/ZODB/tests/testConnectionSavepoint.py 2005-04-24 03:33:29 UTC (rev 30131)
@@ -33,6 +33,21 @@
>>> transaction.abort()
"""
+
+def testModifyThenSavePointThenModifySomeMoreThenCommit():
+ """
+ >>> import ZODB.tests.util
+ >>> db = ZODB.tests.util.DB()
+ >>> connection = db.open()
+ >>> root = connection.root()
+ >>> sp = transaction.savepoint()
+ >>> root['a'] = 1
+ >>> sp = transaction.savepoint()
+ >>> root['a'] = 2
+ >>> transaction.commit()
+
+"""
+
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('testConnectionSavepoint.txt'),
More information about the Zodb-checkins
mailing list