[Zope3-checkins] CVS: Zope3/src/ZODB - Connection.py:1.140.2.3

Jeremy Hylton jeremy at zope.com
Mon Mar 29 14:15:20 EST 2004


Update of /cvs-repository/Zope3/src/ZODB
In directory cvs.zope.org:/tmp/cvs-serv13538

Modified Files:
      Tag: jeremy-txn-branch
	Connection.py 
Log Message:
Make sure added objects aren't registered multiple times.


=== Zope3/src/ZODB/Connection.py 1.140.2.2 => 1.140.2.3 ===
--- Zope3/src/ZODB/Connection.py:1.140.2.2	Mon Mar 22 16:36:28 2004
+++ Zope3/src/ZODB/Connection.py	Mon Mar 29 14:15:19 2004
@@ -310,10 +310,13 @@
             assert obj._p_oid is None
             oid = obj._p_oid = self._storage.new_oid()
             obj._p_jar = self
-            self._added[oid] = obj
             if self._added_during_commit is not None:
                 self._added_during_commit.append(obj)
             self.getTransaction().register(obj)
+            # Add to _added after calling register(), so that _added
+            # can be used as a test for whether the object has been
+            # registered with the transaction.
+            self._added[oid] = obj
         elif obj._p_jar is not self:
             raise InvalidObjectReference(obj, obj._p_jar)
 
@@ -653,6 +656,9 @@
             # a way, this will be a very confusing warning.
             warnings.warn("Assigning to _p_jar is deprecated",
                           DeprecationWarning)
+        elif obj._p_oid in self._added:
+            # It was registered before it was added to _added.
+            return
         self.getTransaction().register(obj)
 
     def root(self):




More information about the Zope3-Checkins mailing list