[Zope-Checkins] CVS: Products/OFSP - Draft.py:1.20.4.1.30.1
Tres Seaver
tseaver at palladion.com
Sat May 28 20:42:12 EDT 2005
Update of /cvs-repository/Products/OFSP
In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/Products/OFSP
Modified Files:
Tag: tseaver-hasattr_geddon-branch
Draft.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?
=== Products/OFSP/Draft.py 1.20.4.1 => 1.20.4.1.30.1 ===
--- Products/OFSP/Draft.py:1.20.4.1 Mon Nov 17 17:34:09 2003
+++ Products/OFSP/Draft.py Sat May 28 20:41:32 2005
@@ -14,6 +14,7 @@
from Globals import Persistent
from Acquisition import Implicit
from OFS import SimpleItem
+from ZODB.utils import safe_hasattr
manage_addPrincipiaDraftForm=Globals.HTMLFile('dtml/draftAdd',globals())
def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None):
@@ -90,7 +91,8 @@
dself=getdraft(self, jar)
ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself)
- if hasattr(ref, name): return dself, ref, getattr(ref, name)
+ if safe_hasattr(ref, name):
+ return dself, ref, getattr(ref, name)
return getattr(self, name)
def nonempty(self):
@@ -150,10 +152,11 @@
def getdraft(ob, jar):
- if hasattr(ob,'aq_parent'):
+ if safe_hasattr(ob,'aq_parent'):
return getdraft(ob.aq_self, jar).__of__(getdraft(ob.aq_parent, jar))
- if hasattr(ob,'_p_oid'): ob=jar[ob._p_oid]
+ if safe_hasattr(ob,'_p_oid'):
+ ob=jar[ob._p_oid]
return ob
More information about the Zope-Checkins
mailing list