Log message for revision 30234:
  fixed reindexing of objects evaluating to False
  

Changed:
  U   Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py
  U   Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py
===================================================================
--- Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2005-05-03 08:09:03 UTC 
(rev 30233)
+++ Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2005-05-03 12:59:42 UTC 
(rev 30234)
@@ -487,7 +487,7 @@
             if pghandler: pghandler.report(i)
 
             obj = self.resolve_path(p)
-            if not obj:
+            if obj is None:
                 obj = self.resolve_url(p, REQUEST)
             if obj is None:
                 LOG.error('reindexIndex could not resolve '

Modified: Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
===================================================================
--- Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py        
2005-05-03 08:09:03 UTC (rev 30233)
+++ Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py        
2005-05-03 12:59:42 UTC (rev 30234)
@@ -155,6 +155,12 @@
     def title(self):
         return '%d' % self.num
 
+class zdummyFalse(zdummy):
+
+    def __nonzero__(self):
+        return False
+
+
 class TestZCatalog(unittest.TestCase):
     def setUp(self):
         from Products.ZCatalog.ZCatalog import ZCatalog
@@ -171,7 +177,7 @@
             ob = zdummy(x)
             self.d[str(x)] = ob
             self._catalog.catalog_object(ob, str(x))
-
+        
     def _resolve_num(self, num):
         return self.d[num]
 
@@ -212,6 +218,19 @@
         self._catalog.reindexIndex('title', {})
         data = self._catalog.getMetadataForUID('0')
         self.assertEqual(data['title'], '0')
+    
+    def testReindexIndexesFalse(self):
+        # setup
+        false_id = self.upper + 1
+        ob = zdummyFalse(false_id)
+        self.d[str(false_id)] = ob
+        self._catalog.catalog_object(ob, str(false_id))
+        # test, object evaluates to false; there was bug which caused the
+        # object to be removed from index
+        ob.num = 9999
+        self._catalog.reindexIndex('title', {})
+        result = self._catalog(title='9999')
+        self.assertEquals(1, len(result))
 
     def test_interface(self):
         from Products.ZCatalog.IZCatalog import IZCatalog

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to