[Zope-Checkins] CVS: Products/ZCTextIndex - Lexicon.py:1.19.64.1 ZCTextIndex.py:1.48.2.2.2.1

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


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

Modified Files:
      Tag: tseaver-hasattr_geddon-branch
	Lexicon.py ZCTextIndex.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/ZCTextIndex/Lexicon.py 1.19 => 1.19.64.1 ===
--- Products/ZCTextIndex/Lexicon.py:1.19	Thu Jun  5 15:43:54 2003
+++ Products/ZCTextIndex/Lexicon.py	Sat May 28 20:41:34 2005
@@ -19,6 +19,7 @@
 from BTrees.Length import Length
 
 import ZODB
+from ZODB.utils import safe_hasattr
 from Persistence import Persistent
 
 from Products.ZCTextIndex.ILexicon import ILexicon
@@ -59,7 +60,7 @@
         last = _text2list(text)
         for element in self._pipeline:
             last = element.process(last)
-        if not hasattr(self.length, 'change'):
+        if not safe_hasattr(self.length, 'change'):
             # Make sure length is overridden with a BTrees.Length.Length
             self.length = Length(self.length())        
         # Strategically unload the length value so that we get the most


=== Products/ZCTextIndex/ZCTextIndex.py 1.48.2.2 => 1.48.2.2.2.1 ===
--- Products/ZCTextIndex/ZCTextIndex.py:1.48.2.2	Tue May 17 14:10:40 2005
+++ Products/ZCTextIndex/ZCTextIndex.py	Sat May 28 20:41:34 2005
@@ -18,6 +18,7 @@
 from types import TupleType
 
 import ZODB
+from ZODB.utils import safe_hasattr
 from Persistence import Persistent
 import Acquisition
 from Acquisition import aq_base, aq_inner, aq_parent
@@ -106,7 +107,7 @@
     def getLexicon(self):
         """Get the lexicon for this index
         """
-        if hasattr(aq_base(self), 'lexicon'):
+        if safe_hasattr(aq_base(self), 'lexicon'):
             # Fix up old ZCTextIndexes by removing direct lexicon ref
             # and changing it to an ID
             lexicon = getattr(aq_parent(aq_inner(self)), self.lexicon.getId())
@@ -272,7 +273,7 @@
 
     pipeline = []
     for el_record in elements:
-        if not hasattr(el_record, 'name'):
+        if not safe_hasattr(el_record, 'name'):
             continue # Skip over records that only specify element group
         element = element_factory.instantiate(el_record.group, el_record.name)
         if element is not None:



More information about the Zope-Checkins mailing list