[Zodb-checkins] CVS: ZODB3/ZODB - Connection.py:1.96

Jeremy Hylton jeremy at zope.com
Fri Jun 13 14:00:05 EDT 2003


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv22543

Modified Files:
	Connection.py 
Log Message:
Eliminate duplicate code in _handle_serials().


=== ZODB3/ZODB/Connection.py 1.95 => 1.96 ===
--- ZODB3/ZODB/Connection.py:1.95	Fri Jun 13 12:54:43 2003
+++ ZODB3/ZODB/Connection.py	Fri Jun 13 13:00:04 2003
@@ -725,31 +725,24 @@
         if not store_return:
             return
         if isinstance(store_return, StringType):
-            # This code is duplicated in the body of the for loop below.
             assert oid is not None
-            serial = store_return
-            obj = self._cache.get(oid, None)
-            if obj is None:
-                return
-            if serial == ResolvedSerial:
-                del obj._p_changed # transition from changed to ghost
-            else:
-                if change:
-                    obj._p_changed = 0 # transition from changed to uptodate
-                obj._p_serial = serial
+            self._handle_one_serial(oid, store_return, change)
         else:
             for oid, serial in store_return:
-                if not isinstance(serial, StringType):
-                    raise serial
-                obj = self._cache.get(oid, None)
-                if obj is None:
-                    continue
-                if serial == ResolvedSerial:
-                    del obj._p_changed # transition from changed to ghost
-                else:
-                    if change:
-                        obj._p_changed = 0 # trans. from changed to uptodate
-                    obj._p_serial = serial
+                self._handle_one_serial(oid, serial, change)
+
+    def _handle_one_serial(self, oid, serial, change):
+        if not isinstance(serial, StringType):
+            raise serial
+        obj = self._cache.get(oid, None)
+        if obj is None:
+            return
+        if serial == ResolvedSerial:
+            del obj._p_changed # transition from changed to ghost
+        else:
+            if change:
+                obj._p_changed = 0 # trans. from changed to uptodate
+            obj._p_serial = serial
 
     def tpc_finish(self, transaction):
         # It's important that the storage call the function we pass




More information about the Zodb-checkins mailing list