[Zope3-checkins] CVS: ZODB4/ZODB - Serialize.py:1.9.6.1

Jeremy Hylton jeremy@zope.com
Tue, 10 Dec 2002 17:01:10 -0500


Update of /cvs-repository/ZODB4/ZODB
In directory cvs.zope.org:/tmp/cvs-serv23006/ZODB

Modified Files:
      Tag: ZODB4-Q-branch
	Serialize.py 
Log Message:
Rename variable object to obj.

It's just too confusing to have a variable name that shadows a
builtin.




=== ZODB4/ZODB/Serialize.py 1.9 => 1.9.6.1 ===
--- ZODB4/ZODB/Serialize.py:1.9	Tue Dec  3 18:07:05 2002
+++ ZODB4/ZODB/Serialize.py	Tue Dec 10 17:01:10 2002
@@ -63,13 +63,14 @@
         mod = getattr(mod, part)
     return getattr(mod, name)
 
-def getClassMetadata(object=None, klass=None):
+def getClassMetadata(obj=None, klass=None):
     if klass is None:
-        klass = object.__class__
+        klass = obj.__class__
     module = klass.__module__
     classname = klass.__name__
-    if hasattr(object, "__getnewargs__"):
-        newargs = object.__getnewargs__()
+    # XXX what if obj is None and we were passed klass?
+    if hasattr(obj, "__getnewargs__"):
+        newargs = obj.__getnewargs__()
     else:
         newargs = None
     return module, classname, newargs
@@ -177,11 +178,11 @@
     def _new_object(self, module, classname, newargs=None):
         klass = getClass(module, classname)
         if newargs is None:
-            object = klass.__new__(klass)
+            obj = klass.__new__(klass)
         else:
-            object = klass.__new__(klass, *newargs)
+            obj = klass.__new__(klass, *newargs)
                 
-        return object
+        return obj
 
     def getClassName(self, pickle):
         unpickler = self._get_unpickler(pickle)
@@ -206,10 +207,10 @@
     def getObject(self, pickle):
         unpickler = self._get_unpickler(pickle)
         module, classname, newargs = unpickler.load()
-        object = self._new_object(module, classname, newargs)
+        obj = self._new_object(module, classname, newargs)
         state = unpickler.load()
-        object.__setstate__(state)
-        return object
+        obj.__setstate__(state)
+        return obj
 
 class SimpleObjectReader(BaseObjectReader):
     """Minimal reader for a single data record."""
@@ -231,23 +232,23 @@
             # Quick instance reference.  We know all we need to know
             # to create the instance w/o hitting the db, so go for it!
             oid, classmeta = oid
-            object = self._cache.get(oid)
-            if object is not None:
-                return object
+            obj = self._cache.get(oid)
+            if obj is not None:
+                return obj
 
-            object = self._new_object(*classmeta)
+            obj = self._new_object(*classmeta)
 
             # XXX should be done by connection
-            object._p_oid = oid
-            object._p_jar = self._conn
-            object._p_changed = None
+            obj._p_oid = oid
+            obj._p_jar = self._conn
+            obj._p_changed = None
             
-            self._cache[oid] = object
-            return object
+            self._cache[oid] = obj
+            return obj
 
-        object = self._cache.get(oid)
-        if object is not None:
-            return object
+        obj = self._cache.get(oid)
+        if obj is not None:
+            return obj
         return self._conn[oid]
 
 class CopyReference: