Update of /cvs-repository/Packages/ZTUtils In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/ZTUtils
Modified Files: Tag: tseaver-hasattr_geddon-branch Tree.py Zope.py Log Message: - Removed all uses of the 'hasattr' builtin from the core, where the object being tested derives (or might) from Persistent. XXX: currently, this branch imports a 'safe_hasattr' from ZODB.utils, which adds a dependency on ZODB for some packages; we probably need a better location, and perhas a C implementation? === Packages/ZTUtils/Tree.py 1.15.2.5 => 1.15.2.5.22.1 === --- Packages/ZTUtils/Tree.py:1.15.2.5 Tue May 4 15:31:09 2004 +++ Packages/ZTUtils/Tree.py Sat May 28 20:41:38 2005 @@ -17,6 +17,7 @@ from Acquisition import Explicit from ComputedAttribute import ComputedAttribute +from ZODB.utils import safe_hasattr from types import ListType, TupleType class TreeNode(Explicit): @@ -177,11 +178,13 @@ def getId(self, object): id_attr = self._id - if hasattr(object, id_attr): + if safe_hasattr(object, id_attr): obid = getattr(object, id_attr) - if not simple_type(obid): obid = obid() + if not simple_type(obid): + obid = obid() return obid - if hasattr(object, '_p_oid'): return str(object._p_oid) + if safe_hasattr(object, '_p_oid'): + return str(object._p_oid) return id(object) def hasChildren(self, object): === Packages/ZTUtils/Zope.py 1.11.42.6 => 1.11.42.6.26.1 === --- Packages/ZTUtils/Zope.py:1.11.42.6 Tue Jan 27 10:45:35 2004 +++ Packages/ZTUtils/Zope.py Sat May 28 20:41:38 2005 @@ -22,6 +22,7 @@ from Products.ZCatalog.Lazy import Lazy from AccessControl import getSecurityManager from DateTime import DateTime +from ZODB.utils import safe_hasattr try: from AccessControl.ZopeGuards import guarded_getitem @@ -233,7 +234,7 @@ sublist = None if isinstance(v, str): pass - elif hasattr(v, 'items'): + elif safe_hasattr(v, 'items'): sublist = [] for sk, sv in v.items(): sm = simple_marshal(sv) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins