[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex - PathIndex.py:1.35
Sidnei da Silva
sidnei@x3ng.com.br
Tue, 17 Jun 2003 15:01:38 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/PathIndex
In directory cvs.zope.org:/tmp/cvs-serv17889/lib/python/Products/PluginIndexes/PathIndex
Modified Files:
PathIndex.py
Log Message:
- Made all PluginIndexes and ZCTextIndex use 'safe_callable',
which is aware of extension classes that fill 'tp_callable'
but don't define '__call__'.
- Made KeywordIndex be more robust about receiving a value that
is not a string or an iterable type.
=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.34 => 1.35 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.34 Tue May 27 01:31:21 2003
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Tue Jun 17 15:01:07 2003
@@ -15,6 +15,7 @@
from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest
+from Products.PluginIndexes.common import safe_callable
from Globals import Persistent, DTMLFile
from Acquisition import Implicit
@@ -65,7 +66,7 @@
self.useOperator = 'or'
self.clear()
-
+
def clear(self):
""" clear everything """
@@ -73,11 +74,11 @@
self._depth = 0
self._index = OOBTree()
self._unindex = IOBTree()
-
+
def insertEntry(self, comp, id, level):
"""Insert an entry.
-
+
comp is a path component (generated by splitPath() )
id is the documentId
level is the level of the component inside the path
@@ -102,8 +103,8 @@
if hasattr(obj, self.id):
f = getattr(obj, self.id)
-
- if callable(f):
+
+ if safe_callable(f):
try:
path = f()
except AttributeError:
@@ -141,7 +142,7 @@
'Attempt to unindex nonexistent document'
' with id %s' % documentId)
return
-
+
path = self._unindex[documentId]
comps = path.split('/')
@@ -219,7 +220,7 @@
if not self._index[comp].has_key(level+i): return IISet()
results.append( self._index[comp][level+i] )
-
+
res = results[0]
for i in range(1,len(results)):
@@ -323,8 +324,8 @@
def hasUniqueValuesFor(self, name):
"""has unique values for column name"""
return name == self.id
-
-
+
+
def uniqueValues(self, name=None, withLength=0):
""" needed to be consistent with the interface """
return self._index.keys()