Skip to content

Commit

Permalink
Merge 66df038 into ff3ee17
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Nov 15, 2019
2 parents ff3ee17 + 66df038 commit f382382
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Products/CMFCore/CMFCatalogAware.py
Expand Up @@ -79,7 +79,7 @@ def unindexObject(self):
catalog.unindexObject(self)

@security.protected(ModifyPortalContent)
def reindexObject(self, idxs=[]):
def reindexObject(self, idxs=[], update_metadata=1, uid=False):
""" Reindex the object in the portal catalog.
"""
if idxs == []:
Expand All @@ -88,7 +88,11 @@ def reindexObject(self, idxs=[]):
self.notifyModified()
catalog = self._getCatalogTool()
if catalog is not None:
catalog.reindexObject(self, idxs=idxs)
catalog.reindexObject(
self,
idxs=idxs,
update_metadata=update_metadata,
uid=uid)

_cmf_security_indexes = ('allowedRolesAndUsers',)

Expand Down
25 changes: 17 additions & 8 deletions Products/CMFCore/tests/test_CMFCatalogAware.py
Expand Up @@ -93,7 +93,8 @@ def indexObject(self, ob):
self.log.append('index %s' % physicalpath(ob))

def reindexObject(self, ob, idxs=[], update_metadata=0, uid=None):
self.log.append('reindex %s %s' % (physicalpath(ob), idxs))
self.log.append(
'reindex %s %s %i' % (physicalpath(ob), idxs, update_metadata))

def unindexObject(self, ob):
self.log.append('unindex %s' % physicalpath(ob))
Expand Down Expand Up @@ -165,16 +166,23 @@ def test_reindexObject(self):
foo = self.site.foo
cat = self.ctool
foo.reindexObject()
self.assertEqual(cat.log, ['reindex /site/foo []'])
self.assertEqual(cat.log, ['reindex /site/foo [] 1'])
self.assertTrue(foo.notified)

def test_reindexObject_idxs(self):
foo = self.site.foo
cat = self.ctool
foo.reindexObject(idxs=['bar'])
self.assertEqual(cat.log, ["reindex /site/foo ['bar']"])
self.assertEqual(cat.log, ["reindex /site/foo ['bar'] 1"])
self.assertFalse(foo.notified)

def test_reindexObject_metadata(self):
foo = self.site.foo
cat = self.ctool
foo.reindexObject(update_metadata=0)
self.assertEqual(cat.log, ['reindex /site/foo [] 0'])
self.assertTrue(foo.notified)

def test_reindexObjectSecurity(self):
foo = self.site.foo
self.site.foo.bar = TheClass('bar')
Expand All @@ -186,9 +194,9 @@ def test_reindexObjectSecurity(self):
foo.reindexObjectSecurity()
log = sorted(cat.log)
self.assertEqual(log, [
'reindex /site/foo %s' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/bar %s' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/hop %s' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo %s 1' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/bar %s 1' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/hop %s 1' % str(CMF_SECURITY_INDEXES),
])
self.assertFalse(foo.notified)
self.assertFalse(bar.notified)
Expand Down Expand Up @@ -217,8 +225,9 @@ def test_reindexObjectSecurity_missing_noraise(self):
cat = self.ctool
cat.setObs([foo, missing])
foo.reindexObjectSecurity()
self.assertEqual(cat.log,
['reindex /site/foo %s' % str(CMF_SECURITY_INDEXES)])
self.assertEqual(
cat.log,
['reindex /site/foo %s 1' % str(CMF_SECURITY_INDEXES)])
self.assertFalse(foo.notified)
self.assertFalse(missing.notified)
self.assertEqual(len(self.logged), 1) # logging because no raise
Expand Down

0 comments on commit f382382

Please sign in to comment.