[Zope3-checkins] CVS: Zope3/src/zodb - serialize.py:1.11
Jeremy Hylton
jeremy@zope.com
Fri, 7 Mar 2003 18:42:12 -0500
Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv21032
Modified Files:
serialize.py
Log Message:
Remove hasattr() in preference to getattr().
Remove log warning when _p_oid is a descriptor.
=== Zope3/src/zodb/serialize.py 1.10 => 1.11 ===
--- Zope3/src/zodb/serialize.py:1.10 Fri Mar 7 18:09:51 2003
+++ Zope3/src/zodb/serialize.py Fri Mar 7 18:42:11 2003
@@ -127,17 +127,17 @@
If it is persistent, it returns the oid and sometimes a tuple
with other stuff.
"""
- if not hasattr(obj, '_p_oid'):
+ oid = getattr(obj, "_p_oid", None)
+ if oid is None:
return None
- oid = obj._p_oid
-
# I'd like to write something like this --
# if isinstance(oid, types.MemberDescriptor):
# -- but I can't because the type doesn't have a canonical name.
# Instead, we'll assert that an oid must always be a string
+ # This case occurs when obj is a class that contains a descriptor
+ # for _p_oid.
if not (oid is None or isinstance(oid, StringType)):
- logging.warn("unexpected _p_oid: %r", oid)
return None
if oid is None or obj._p_jar is not self._jar: