Fix indentation.

svn path=/plone.app.discussion/trunk/; revision=39322
This commit is contained in:
Timo Stollenwerk 2010-08-28 19:45:53 +00:00
parent 4390b8929b
commit 318afe5aae

View File

@ -11,36 +11,38 @@ from plone.app.discussion.conversation import ANNOTATION_KEY
# security.declareProtected(ManageZCatalogEntries, 'clearFindAndRebuild') # security.declareProtected(ManageZCatalogEntries, 'clearFindAndRebuild')
def patchedClearFindAndRebuild(self): def patchedClearFindAndRebuild(self):
"""Empties catalog, then finds all contentish objects (i.e. objects """Empties catalog, then finds all contentish objects (i.e. objects
with an indexObject method), and reindexes them. with an indexObject method), and reindexes them.
This may take a long time. This may take a long time.
""" """
def indexObject(obj, path):
if (base_hasattr(obj, 'indexObject') and def indexObject(obj, path):
safe_callable(obj.indexObject)):
try: if (base_hasattr(obj, 'indexObject') and
obj.indexObject() safe_callable(obj.indexObject)):
annotions = IAnnotations(obj) try:
catalog = getToolByName(obj, 'portal_catalog', None) obj.indexObject()
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: annotions = IAnnotations(obj)
# Catalogs have 'indexObject' as well, but they catalog = getToolByName(obj, 'portal_catalog', None)
# take different args, and will fail if ANNOTATION_KEY in annotions:
pass 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
self.manage_catalogClear()
portal = aq_parent(aq_inner(self))
portal.ZopeFindAndApply(portal, search_sub=True, apply_func=indexObject)
self.manage_catalogClear()
portal = aq_parent(aq_inner(self))
portal.ZopeFindAndApply(portal, search_sub=True, apply_func=indexObject)