diff --git a/plone/app/discussion/patches.py b/plone/app/discussion/patches.py index 5df8dff..3b4df60 100644 --- a/plone/app/discussion/patches.py +++ b/plone/app/discussion/patches.py @@ -11,36 +11,38 @@ from plone.app.discussion.conversation import ANNOTATION_KEY # security.declareProtected(ManageZCatalogEntries, 'clearFindAndRebuild') def patchedClearFindAndRebuild(self): - """Empties catalog, then finds all contentish objects (i.e. objects - with an indexObject method), and reindexes them. - This may take a long time. - """ - def indexObject(obj, path): + """Empties catalog, then finds all contentish objects (i.e. objects + with an indexObject method), and reindexes them. + This may take a long time. + """ + + def indexObject(obj, path): - if (base_hasattr(obj, 'indexObject') and - safe_callable(obj.indexObject)): + if (base_hasattr(obj, 'indexObject') and + safe_callable(obj.indexObject)): - try: - obj.indexObject() + try: + obj.indexObject() - annotions = IAnnotations(obj) - catalog = getToolByName(obj, 'portal_catalog', None) - if ANNOTATION_KEY in annotions: - conversation = annotions[ANNOTATION_KEY] - conversation = conversation.__of__(obj) - for comment in conversation.getComments(): - try: - comment = comment.__of__(conversation) - if catalog: - catalog.indexObject(comment) - except StopIteration: - pass + annotions = IAnnotations(obj) + catalog = getToolByName(obj, 'portal_catalog', None) + if ANNOTATION_KEY in annotions: + conversation = annotions[ANNOTATION_KEY] + conversation = conversation.__of__(obj) + for comment in conversation.getComments(): + try: + comment = comment.__of__(conversation) + if catalog: + catalog.indexObject(comment) + except StopIteration: + pass - except TypeError: - # Catalogs have 'indexObject' as well, but they - # take different args, and will fail - pass + except TypeError: + # Catalogs have 'indexObject' as well, but they + # take different args, and will fail + pass - self.manage_catalogClear() - portal = aq_parent(aq_inner(self)) - portal.ZopeFindAndApply(portal, search_sub=True, apply_func=indexObject) \ No newline at end of file + self.manage_catalogClear() + portal = aq_parent(aq_inner(self)) + portal.ZopeFindAndApply(portal, search_sub=True, apply_func=indexObject) + \ No newline at end of file