[Zope-Checkins]
CVS: Zope/lib/python/Products/PluginIndexes/TopicIndex
- FilteredSet.py:1.5.2.1 TopicIndex.py:1.13.2.2
Gary Poster
gary at zope.com
Wed Dec 31 16:09:55 EST 2003
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TopicIndex
In directory cvs.zope.org:/tmp/cvs-serv29452
Modified Files:
Tag: Zope-2_7-branch
FilteredSet.py TopicIndex.py
Log Message:
Fix TopicIndex in two ways:
1) items added to a topic index PythonFilteredSet could never be removed upon a reindex, even if they no longer evaluated to be true. This is fixed.
2) Casey informs me that a IITreeSet is better for this application that an IISet. This should be a transparent change simply by relying on the keys method, which both have, rather than the iterable IISet.
=== Zope/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py 1.5 => 1.5.2.1 ===
--- Zope/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py:1.5 Thu Jun 12 10:36:47 2003
+++ Zope/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py Wed Dec 31 16:09:24 2003
@@ -13,7 +13,8 @@
__version__ = '$Id$'
-from BTrees.IIBTree import IISet
+from ZODB.POSException import ConflictError
+from BTrees.IIBTree import IITreeSet
from Persistence import Persistent
from Globals import DTMLFile
from zLOG import WARNING,LOG
@@ -29,7 +30,7 @@
def clear(self):
- self.ids = IISet()
+ self.ids = IITreeSet()
def index_object(self, documentId, obj):
@@ -41,10 +42,17 @@
except KeyError: pass
- def getId(self): return self.id
- def getExpression(self): return self.expr
- def getIds(self): return self.ids
- def getType(self): return self.meta_type
+ def getId(self):
+ return self.id
+
+ def getExpression(self):
+ return self.expr
+
+ def getIds(self):
+ return self.ids
+
+ def getType(self):
+ return self.meta_type
def setExpression(self, expr): self.expr = expr
@@ -60,9 +68,16 @@
meta_type = 'PythonFilteredSet'
def index_object(self, documentId, o):
-
try:
- if eval(self.expr): self.ids.insert(documentId)
+ if eval(self.expr): # XXX trusted code!
+ self.ids.insert(documentId)
+ else:
+ try:
+ self.ids.remove(documentId)
+ except KeyError:
+ pass
+ except ConflictError:
+ raise
except:
LOG('FilteredSet',WARNING,'eval() failed',\
'Object: %s, expr: %s' % (o.getId(),self.expr),\
=== Zope/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py 1.13.2.1 => 1.13.2.2 ===
--- Zope/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py:1.13.2.1 Thu Sep 18 10:16:15 2003
+++ Zope/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py Wed Dec 31 16:09:24 2003
@@ -100,7 +100,7 @@
res = set_func(res,rows)
if res:
- return res, (self.id,)
+ return res.keys(), (self.id,)
else:
return IISet(), (self.id,)
More information about the Zope-Checkins
mailing list