[Zodb-checkins] SVN: ZODB/branches/3.9/src/ZODB/ Fixed a bug that caused savepoint rollback to not properly
Jim Fulton
jim at zope.com
Fri Apr 23 13:30:13 EDT 2010
Log message for revision 111314:
Fixed a bug that caused savepoint rollback to not properly
set object state when objects implemented _p_invalidate methods
that reloaded ther state (unghostifiable objects).
https://bugs.launchpad.net/zodb/+bug/428039
Changed:
U ZODB/branches/3.9/src/ZODB/Connection.py
U ZODB/branches/3.9/src/ZODB/tests/testConnectionSavepoint.py
-=-
Modified: ZODB/branches/3.9/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.9/src/ZODB/Connection.py 2010-04-23 17:28:55 UTC (rev 111313)
+++ ZODB/branches/3.9/src/ZODB/Connection.py 2010-04-23 17:30:12 UTC (rev 111314)
@@ -1143,8 +1143,9 @@
self._abort()
self._registered_objects = []
src = self._storage
- self._cache.invalidate(src.index)
+ index = src.index
src.reset(*state)
+ self._cache.invalidate(index)
def _commit_savepoint(self, transaction):
"""Commit all changes made in savepoints and begin 2-phase commit
Modified: ZODB/branches/3.9/src/ZODB/tests/testConnectionSavepoint.py
===================================================================
--- ZODB/branches/3.9/src/ZODB/tests/testConnectionSavepoint.py 2010-04-23 17:28:55 UTC (rev 111313)
+++ ZODB/branches/3.9/src/ZODB/tests/testConnectionSavepoint.py 2010-04-23 17:30:12 UTC (rev 111314)
@@ -154,6 +154,34 @@
False
"""
+class SelfActivatingObject(persistent.Persistent):
+
+ def _p_invalidate(self):
+ super(SelfActivatingObject, self)._p_invalidate()
+ self._p_activate()
+
+def testInvalidateAfterRollback():
+ """\
+The rollback used to invalidate objects before resetting the TmpStore.
+This caused problems for custom _p_invalidate methods that would load
+the wrong state.
+
+ >>> import ZODB.tests.util
+ >>> db = ZODB.tests.util.DB()
+ >>> connection = db.open()
+ >>> root = connection.root()
+
+ >>> root['p'] = p = SelfActivatingObject()
+ >>> transaction.commit()
+ >>> p.foo = 1
+ >>> sp = transaction.savepoint()
+ >>> p.foo = 2
+ >>> sp2 = transaction.savepoint()
+ >>> sp.rollback()
+ >>> p.foo # This used to wrongly return 2
+ 1
+ """
+
def tearDown(test):
transaction.abort()
More information about the Zodb-checkins
mailing list