Skip to content

Commit

Permalink
when reindexing an object that got a uid, try the object's reindexObj…
Browse files Browse the repository at this point in the history
…ect attribute first. refs https://bugs.launchpad.net/bugs/290982
  • Loading branch information
davisagli committed Oct 30, 2008
1 parent 623fc0e commit 1152d48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Products/CMFUid/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Products.CMFUid Changelog
2.2.0 (unreleased)
------------------

- UniqueIdHandlerTool: Call the reindexObject attribute of the object
getting a uid, rather than portal_catalog's reindexObject. This is
needed to properly handle objects like the portal itself which shouldn't
get catalogued ever.

- Removed redundant and unexpected code to auto-create catalog index and
column for the UID handler tool. The index and column are already
created by the default CMFUid GenericSetup profile.
Expand Down
5 changes: 4 additions & 1 deletion Products/CMFUid/UniqueIdHandlerTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def _setUid(self, obj, uid):
annotation.setUid(uid)

# reindex the object
self._reindexObject(obj)
try:
obj.reindexObject()
except AttributeError:
self._reindexObject(obj)

security.declarePublic('register')
def register(self, obj):
Expand Down
12 changes: 12 additions & 0 deletions Products/CMFUid/tests/test_uidhandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ def test_UidCatalogingDoesNotAcquireUid(self):
brains = catalog(cmf_uid=uid)
self.assertEqual(len(brains), 1)

def test_UidCatalogingDoesNotCatalogPortalRoot(self):
handler = self.root.portal_uidhandler
catalog = self.root.portal_catalog
dummy = self.root.dummy

# mock the portal root, which has empty indexing attributes
dummy.reindexObject = lambda: None

uid = handler.register(dummy)
brains = catalog(cmf_uid=uid)
self.assertEqual(len(brains), 0)


def test_suite():
return unittest.TestSuite((
Expand Down

0 comments on commit 1152d48

Please sign in to comment.