[Zodb-checkins] CVS: Zope3/src/zodb - connection.py:1.30

Jeremy Hylton jeremy@zope.com
Thu, 10 Apr 2003 13:23:49 -0400


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

Modified Files:
	connection.py 
Log Message:
Small fixes.

Don't worry about objects passed to setstate() that don't have an
_p_oid.
Don't use hasattr() to look for _p_independent; it eats exceptions.


=== Zope3/src/zodb/connection.py 1.29 => 1.30 ===
--- Zope3/src/zodb/connection.py:1.29	Wed Apr  2 14:54:48 2003
+++ Zope3/src/zodb/connection.py	Thu Apr 10 13:23:49 2003
@@ -166,10 +166,14 @@
     # setstate(), register(), mtime()
 
     def setstate(self, obj):
-        # extremely paranoid: guard against obj not having an _p_oid.
-        oid = None
+        oid = obj._p_oid
+        
+        if not self._open:
+            msg = "Attempt to load object on closed connection: %r" % oid
+            self._log.warn(msg)
+            raise POSError(msg)
+            
         try:
-            oid = obj._p_oid
             # Avoid reading data from a transaction that committed
             # after the current transaction started, as that might
             # lead to mixing of cached data from earlier transactions
@@ -200,8 +204,9 @@
         self._inv_lock.acquire()
         try:
             if obj._p_oid in self._invalidated:
-                # Defer _p_independent() call until state is loaded.
-                if hasattr(obj, "_p_independent"):
+                ind = getattr(obj, "_p_independent", None)
+                if ind is not None:
+                    # Defer _p_independent() call until state is loaded.
                     return True
                 else:
                     self._get_transaction().join(self)
@@ -358,7 +363,7 @@
             self._objcommit(obj, txn)
         self.importHook(txn) # hook for ExportImport
 
-        # The tpc_finish() of TmpStore returns an UndoInfo object.
+        # The tpcFinish() of TmpStore returns an UndoInfo object.
         undo = self._storage.tpcFinish(txn)
         self._cache.incrgc()
         self._storage._created = self._created