[Zope3-checkins] CVS: Zope3/src/zodb - serialize.py:1.17

Jeremy Hylton jeremy@zope.com
Thu, 20 Mar 2003 13:19:03 -0500


Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv21777

Modified Files:
	serialize.py 
Log Message:
Raise InvalidObjectReference instead of assigning new oid and jar!

Noted during code review with Rys McCusker.


=== Zope3/src/zodb/serialize.py 1.16 => 1.17 ===
--- Zope3/src/zodb/serialize.py:1.16	Mon Mar 17 12:09:41 2003
+++ Zope3/src/zodb/serialize.py	Thu Mar 20 13:19:03 2003
@@ -69,7 +69,7 @@
 import cPickle
 from cStringIO import StringIO
 
-from zodb.interfaces import ZERO
+from zodb.interfaces import ZERO, InvalidObjectReference
 
 
 def getClassMetadata(obj):
@@ -144,12 +144,13 @@
             # XXX log a warning
             return None
 
-        if oid is None or obj._p_jar is not self._jar:
-            # XXX log warning if obj._p_jar is not self
+        if oid is None:
             oid = self._jar.newObjectId()
             obj._p_jar = self._jar
             obj._p_oid = oid
             self._stack.append(obj)
+        elif obj._p_jar is not self._jar:
+            raise InvalidObjectReference(obj, self._jar)
 
         return oid, getClassMetadata(obj)