Merge pull request #3 from pjstevns/master

Fix for broken indexing when clear-and-rebuild catalog.
This commit is contained in:
Timo Stollenwerk 2011-12-21 10:13:50 -08:00
commit 7dc3e0c6f9
2 changed files with 8 additions and 7 deletions

View File

@ -61,7 +61,7 @@ output = ${buildout:directory}/bin/sphinxupload
mode = 755 mode = 755
[sources] [sources]
collective.akismet = svn https://svn.plone.org/svn/collective/collective.autoresizetextarea/trunk collective.akismet = svn https://svn.plone.org/svn/collective/collective.akismet/trunk
collective.autoresizetextarea = svn https://svn.plone.org/svn/collective/collective.autoresizetextarea/trunk collective.autoresizetextarea = svn https://svn.plone.org/svn/collective/collective.autoresizetextarea/trunk
collective.z3cform.norobots = svn https://svn.plone.org/svn/collective/collective.z3cform.norobots/trunk collective.z3cform.norobots = svn https://svn.plone.org/svn/collective/collective.z3cform.norobots/trunk
plone.formwidget.captcha = svn https://svn.plone.org/svn/plone/plone.formwidget.captcha/trunk/ plone.formwidget.captcha = svn https://svn.plone.org/svn/plone/plone.formwidget.captcha/trunk/

View File

@ -1,13 +1,14 @@
from Acquisition import aq_inner, aq_base, aq_parent from zope.component import queryUtility
from Acquisition import aq_inner, aq_parent
from zope.annotation.interfaces import IAnnotations from zope.annotation.interfaces import IAnnotations
from Products.CMFPlone.utils import base_hasattr from Products.CMFPlone.utils import base_hasattr
from Products.CMFPlone.utils import safe_callable from Products.CMFPlone.utils import safe_callable
from Products.CMFCore.utils import getToolByName
from plone.app.discussion.conversation import ANNOTATION_KEY from plone.app.discussion.conversation import ANNOTATION_KEY
from plone.app.discussion.interfaces import ICommentingTool
# security.declareProtected(ManageZCatalogEntries, 'clearFindAndRebuild') # security.declareProtected(ManageZCatalogEntries, 'clearFindAndRebuild')
def patchedClearFindAndRebuild(self): def patchedClearFindAndRebuild(self):
@ -25,14 +26,14 @@ def patchedClearFindAndRebuild(self):
obj.indexObject() obj.indexObject()
annotions = IAnnotations(obj) annotions = IAnnotations(obj)
catalog = getToolByName(obj, 'portal_catalog', None) discussion = queryUtility(ICommentingTool)
if ANNOTATION_KEY in annotions: if ANNOTATION_KEY in annotions:
conversation = annotions[ANNOTATION_KEY] conversation = annotions[ANNOTATION_KEY]
conversation = conversation.__of__(obj) conversation = conversation.__of__(obj)
for comment in conversation.getComments(): for comment in conversation.getComments():
try: try:
if catalog: if discussion:
catalog.indexObject(aq_base(comment)) discussion.indexObject(comment)
except StopIteration: # pragma: no cover except StopIteration: # pragma: no cover
pass pass