[Checkins] SVN: Products.CMFUid/trunk/Products/CMFUid/ when reindexing an object that got a uid, try the object's reindexObject attribute first. refs https://bugs.launchpad.net/bugs/290982

David Glick davidglick at onenw.org
Thu Oct 30 12:16:31 EDT 2008


Log message for revision 92707:
  when reindexing an object that got a uid, try the object's reindexObject attribute first.  refs https://bugs.launchpad.net/bugs/290982

Changed:
  U   Products.CMFUid/trunk/Products/CMFUid/CHANGES.txt
  U   Products.CMFUid/trunk/Products/CMFUid/UniqueIdHandlerTool.py
  U   Products.CMFUid/trunk/Products/CMFUid/tests/test_uidhandling.py

-=-
Modified: Products.CMFUid/trunk/Products/CMFUid/CHANGES.txt
===================================================================
--- Products.CMFUid/trunk/Products/CMFUid/CHANGES.txt	2008-10-30 15:31:45 UTC (rev 92706)
+++ Products.CMFUid/trunk/Products/CMFUid/CHANGES.txt	2008-10-30 16:16:29 UTC (rev 92707)
@@ -4,6 +4,11 @@
 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.

Modified: Products.CMFUid/trunk/Products/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- Products.CMFUid/trunk/Products/CMFUid/UniqueIdHandlerTool.py	2008-10-30 15:31:45 UTC (rev 92706)
+++ Products.CMFUid/trunk/Products/CMFUid/UniqueIdHandlerTool.py	2008-10-30 16:16:29 UTC (rev 92707)
@@ -87,7 +87,10 @@
         annotation.setUid(uid)
 
         # reindex the object
-        self._reindexObject(obj)
+        try:
+            obj.reindexObject()
+        except AttributeError:
+            self._reindexObject(obj)
 
     security.declarePublic('register')
     def register(self, obj):

Modified: Products.CMFUid/trunk/Products/CMFUid/tests/test_uidhandling.py
===================================================================
--- Products.CMFUid/trunk/Products/CMFUid/tests/test_uidhandling.py	2008-10-30 15:31:45 UTC (rev 92706)
+++ Products.CMFUid/trunk/Products/CMFUid/tests/test_uidhandling.py	2008-10-30 16:16:29 UTC (rev 92707)
@@ -276,7 +276,19 @@
         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((
         unittest.makeSuite(UniqueIdHandlerTests),



More information about the Checkins mailing list