[Zope-Checkins]
SVN: Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/
carried forward from Zope-2_8-branch
Zachery Bir
zbir at urbanape.com
Wed Aug 24 13:40:27 EDT 2005
Log message for revision 38072:
carried forward from Zope-2_8-branch
Changed:
U Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/DateIndex.py
U Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
-=-
Modified: Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/DateIndex.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/DateIndex.py 2005-08-24 17:32:25 UTC (rev 38071)
+++ Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/DateIndex.py 2005-08-24 17:40:22 UTC (rev 38072)
@@ -26,6 +26,8 @@
from DateTime.DateTime import DateTime
from Globals import DTMLFile
from OFS.PropertyManager import PropertyManager
+from ZODB.POSException import ConflictError
+from zLOG import LOG, ERROR
from zope.interface import implements
from Products.PluginIndexes.common import safe_callable
@@ -135,6 +137,16 @@
if ConvertedDate != oldConvertedDate:
if oldConvertedDate is not _marker:
self.removeForwardIndexEntry(oldConvertedDate, documentId)
+ if ConvertedDate is _marker:
+ try:
+ del self._unindex[documentId]
+ except ConflictError:
+ raise
+ except:
+ LOG('UnIndex', ERROR,
+ ("Should not happen: ConvertedDate was there,"
+ " now it's not, for document with id %s" %
+ documentId))
if ConvertedDate is not _marker:
self.insertForwardIndexEntry( ConvertedDate, documentId )
Modified: Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py 2005-08-24 17:32:25 UTC (rev 38071)
+++ Zope/trunk/lib/python/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py 2005-08-24 17:40:22 UTC (rev 38072)
@@ -239,7 +239,21 @@
val = (((yr * 12 + mo) * 31 + dy) * 24 + hr) * 60 + mn
self.failUnlessEqual(self._index.getEntryForObject(k), val)
+ def test_removal(self):
+ """ DateIndex would hand back spurious entries when used as a
+ sort_index, because it previously was not removing entries
+ from the _unindex when indexing an object with a value of
+ None. The catalog consults a sort_index's
+ documentToKeyMap() to build the brains.
+ """
+ values = self._values
+ index = self._index
+ self._populateIndex()
+ self._checkApply(self._int_req, [values[7]])
+ index.index_object(7, None)
+ self.failIf(7 in index.documentToKeyMap().keys())
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( DI_Tests ) )
More information about the Zope-Checkins
mailing list