Commit 9e96d4c6 authored by Christian Zagrodnick's avatar Christian Zagrodnick

fixed reindexing of objects evaluating to False

parent 54333499
......@@ -487,7 +487,7 @@ class ZCatalog(Folder, Persistent, Implicit):
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 '
......
......@@ -155,6 +155,12 @@ class zdummy(ExtensionClass.Base):
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 @@ class TestZCatalog(unittest.TestCase):
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 @@ class TestZCatalog(unittest.TestCase):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment