Get rid of the monkey patch on Products.CMFPlone's CatalogTool.
This commit is contained in:
parent
c00e1099a2
commit
fcb4bbf94b
@ -11,7 +11,10 @@ New:
|
||||
|
||||
Fixes:
|
||||
|
||||
- *add item here*
|
||||
- Get rid of the monkey patch on Products.CMFPlone's CatalogTool.
|
||||
Issue https://github.com/plone/Products.CMFPlone/issues/1332
|
||||
[staeff, fredvd]
|
||||
|
||||
|
||||
|
||||
2.4.9 (2015-11-25)
|
||||
|
@ -2,7 +2,6 @@
|
||||
xmlns="http://namespaces.zope.org/zope"
|
||||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
||||
xmlns:i18n="http://namespaces.zope.org/i18n"
|
||||
xmlns:monkey="http://namespaces.plone.org/monkey"
|
||||
xmlns:zcml="http://namespaces.zope.org/zcml"
|
||||
xmlns:five="http://namespaces.zope.org/five"
|
||||
i18n_domain="plone">
|
||||
@ -62,19 +61,6 @@
|
||||
profile="plone.app.discussion:default"
|
||||
/>
|
||||
|
||||
|
||||
<!-- Monkey Patches -->
|
||||
|
||||
<include package="collective.monkeypatcher" />
|
||||
|
||||
<monkey:patch
|
||||
description="This allows Catalog Tool to find comments
|
||||
during clear-and-rebuild catalog"
|
||||
class="Products.CMFPlone.CatalogTool.CatalogTool"
|
||||
original="clearFindAndRebuild"
|
||||
replacement=".patches.patchedClearFindAndRebuild"
|
||||
/>
|
||||
|
||||
<!-- Comments -->
|
||||
|
||||
<class class=".comment.Comment">
|
||||
|
@ -21,6 +21,7 @@ from OFS.event import ObjectWillBeAddedEvent
|
||||
from OFS.event import ObjectWillBeRemovedEvent
|
||||
from OFS.Traversable import Traversable
|
||||
from Products.CMFPlone.interfaces import IHideFromBreadcrumbs
|
||||
from Products.CMFPlone import DISCUSSION_ANNOTATION_KEY as ANNOTATION_KEY
|
||||
from persistent import Persistent
|
||||
from plone.app.discussion.comment import Comment
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
@ -37,12 +38,10 @@ from zope.lifecycleevent import ObjectAddedEvent
|
||||
from zope.lifecycleevent import ObjectCreatedEvent
|
||||
from zope.lifecycleevent import ObjectRemovedEvent
|
||||
|
||||
|
||||
import time
|
||||
|
||||
|
||||
ANNOTATION_KEY = 'plone.app.discussion:conversation'
|
||||
|
||||
|
||||
class Conversation(Traversable, Persistent, Explicit):
|
||||
"""A conversation is a container for all comments on a content object.
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
from Acquisition import aq_inner
|
||||
from Acquisition import aq_parent
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from Products.CMFPlone.utils import base_hasattr
|
||||
from Products.CMFPlone.utils import safe_callable
|
||||
from plone.app.discussion.conversation import ANNOTATION_KEY
|
||||
from zope.annotation.interfaces import IAnnotations
|
||||
|
||||
|
||||
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):
|
||||
|
||||
if (base_hasattr(obj, 'indexObject') and
|
||||
safe_callable(obj.indexObject)):
|
||||
|
||||
try:
|
||||
obj.indexObject()
|
||||
|
||||
annotions = IAnnotations(obj)
|
||||
catalog = getToolByName(obj, "portal_catalog")
|
||||
if ANNOTATION_KEY in annotions:
|
||||
conversation = annotions[ANNOTATION_KEY]
|
||||
conversation = conversation.__of__(obj)
|
||||
for comment in conversation.getComments():
|
||||
try:
|
||||
if catalog:
|
||||
catalog.indexObject(comment)
|
||||
except StopIteration: # pragma: no cover
|
||||
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)
|
Loading…
Reference in New Issue
Block a user