[Checkins] SVN: ZODB/trunk/src/ Added a test for a the "bug":

Jim Fulton jim at zope.com
Wed Sep 22 10:34:37 EDT 2010


Log message for revision 116730:
  Added a test for a the "bug":
  - Object ids created in a savepoint that is rolled back wren't being
    reused. (https://bugs.launchpad.net/zodb/+bug/588389)
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-09-22 14:33:19 UTC (rev 116729)
+++ ZODB/trunk/src/CHANGES.txt	2010-09-22 14:34:36 UTC (rev 116730)
@@ -34,6 +34,9 @@
 - The verbose mode of the fstest was broken.
   (https://bugs.launchpad.net/zodb/+bug/475996)
 
+- Object ids created in a savepoint that is rolled back wren't being
+  reused. (https://bugs.launchpad.net/zodb/+bug/588389)
+
 3.10.0b6 (2010-09-08)
 =====================
 

Modified: ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py	2010-09-22 14:33:19 UTC (rev 116729)
+++ ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py	2010-09-22 14:34:36 UTC (rev 116730)
@@ -15,6 +15,7 @@
 import persistent.mapping
 import transaction
 import unittest
+import ZODB.tests.util
 
 def testAddingThenModifyThenAbort():
     """\
@@ -178,6 +179,57 @@
     1
     """
 
+
+def testNewOidsGetReusedOnRollback():
+    """\
+    New oids assigned during a transaction should be reused on
+    rollback, not just on abort.
+
+    >>> connection = ZODB.connection(None)
+    >>> root = connection.root()
+
+    Let's make a savepoint (with a real change so that the connection
+    is involved, otherwise rolling back to the savepoint will just be
+    an abort).
+
+    >>> root._p_changed = True  # Important!
+    >>> sp = transaction.savepoint()
+
+    Add an object, and make a new savepoint so that it gets an oid.
+
+    >>> root['p'] = p = ZODB.tests.util.P()
+    >>> sp2 = transaction.savepoint()
+    >>> p._p_oid
+    '\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01'
+
+    Rolling back to the first savepoint unassigns the oid, but not
+    before invalidating the object.  If a custom _p_invalidate method
+    tries to reactivate the object *during* rollback, a POSKeyError is
+    raised.
+
+    >>> sp.rollback()
+    >>> p._p_oid is None
+    True
+    >>> p._p_jar is None
+    True
+    >>> print p._p_changed
+    False
+
+    The rest of the state of p is undefined after the rollback.  Using
+    p in any way from this point is a bad idea.
+
+    >>> del p
+
+    If we create a new object and add it, the oid is reused.
+
+    >>> root['p'] = p = ZODB.tests.util.P()
+    >>> connection.add(p)
+    >>> p._p_oid
+    '\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01'
+
+    >>> transaction.abort()
+    """
+
 def tearDown(test):
     transaction.abort()
 



More information about the checkins mailing list