[Zope-Checkins] CVS: Products/PluginIndexes/common - __init__.py:1.5.66.1 util.py:1.10.68.5.22.1

Tres Seaver tseaver at palladion.com
Sat May 28 20:42:13 EDT 2005


Update of /cvs-repository/Products/PluginIndexes/common
In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/Products/PluginIndexes/common

Modified Files:
      Tag: tseaver-hasattr_geddon-branch
	__init__.py util.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/PluginIndexes/common/__init__.py 1.5 => 1.5.66.1 ===
--- Products/PluginIndexes/common/__init__.py:1.5	Tue Jun 24 10:17:18 2003
+++ Products/PluginIndexes/common/__init__.py	Sat May 28 20:41:33 2005
@@ -14,13 +14,14 @@
 # This code is duplicated here from Products/ZCatalog/Catalog.py to avoid a
 # unnecessary dependency on ZCatalog.
 import types
+from ZODB.utils import safe_hasattr
 try:
     from DocumentTemplate.cDocumentTemplate import safe_callable
 except ImportError:
     def safe_callable(ob):
         # Works with ExtensionClasses and Acquisition.
-        if hasattr(ob, '__class__'):
-            if hasattr(ob, '__call__'):
+        if safe_hasattr(ob, '__class__'):
+            if safe_hasattr(ob, '__call__'):
                 return 1
             else:
                 return isinstance(ob, types.ClassType)


=== Products/PluginIndexes/common/util.py 1.10.68.5 => 1.10.68.5.22.1 ===
--- Products/PluginIndexes/common/util.py:1.10.68.5	Tue Jun 29 05:59:50 2004
+++ Products/PluginIndexes/common/util.py	Sat May 28 20:41:33 2005
@@ -18,6 +18,7 @@
 from warnings import warn
 from types import StringType,ListType,TupleType,DictType,InstanceType
 from DateTime import DateTime
+from ZODB.utils import safe_hasattr
 
 SequenceTypes = (TupleType, ListType)
 
@@ -85,7 +86,7 @@
 
             record = param
 
-            if not hasattr(record, 'query'):
+            if not safe_hasattr(record, 'query'):
                 raise self.ParserException, (
                     "record for '%s' *must* contain a "
                     "'query' attribute" % self.id)
@@ -97,7 +98,7 @@
             for op in options:
                 if op == "query": continue
 
-                if hasattr(record, op):
+                if safe_hasattr(record, op):
                     setattr(self, op, getattr(record, op))
 
         elif t is DictType:
@@ -133,7 +134,7 @@
 
     def get(self,k,default_v=None):
 
-        if hasattr(self,k):
+        if safe_hasattr(self,k):
             v = getattr(self,k)
             if v: return v
             else: return default_v



More information about the Zope-Checkins mailing list