Merge pull request #80 from plone/remove-p.a.discussion-monkey

Get rid of the monkey patch on Products.CMFPlone's CatalogTool.
This commit is contained in:
Jens W. Klein 2016-01-31 23:33:33 +01:00
commit fb71aee6cd
5 changed files with 6 additions and 62 deletions

View File

@ -11,7 +11,10 @@ New:
Fixes: 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.4.9 (2015-11-25)

View File

@ -2,7 +2,6 @@
xmlns="http://namespaces.zope.org/zope" xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup" xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:monkey="http://namespaces.plone.org/monkey"
xmlns:zcml="http://namespaces.zope.org/zcml" xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:five="http://namespaces.zope.org/five" xmlns:five="http://namespaces.zope.org/five"
i18n_domain="plone"> i18n_domain="plone">
@ -62,19 +61,6 @@
profile="plone.app.discussion:default" 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 --> <!-- Comments -->
<class class=".comment.Comment"> <class class=".comment.Comment">

View File

@ -21,6 +21,7 @@ from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent from OFS.event import ObjectWillBeRemovedEvent
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
from Products.CMFPlone.interfaces import IHideFromBreadcrumbs from Products.CMFPlone.interfaces import IHideFromBreadcrumbs
from Products.CMFPlone import DISCUSSION_ANNOTATION_KEY as ANNOTATION_KEY
from persistent import Persistent from persistent import Persistent
from plone.app.discussion.comment import Comment from plone.app.discussion.comment import Comment
from plone.app.discussion.interfaces import IConversation 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 ObjectCreatedEvent
from zope.lifecycleevent import ObjectRemovedEvent from zope.lifecycleevent import ObjectRemovedEvent
import time import time
ANNOTATION_KEY = 'plone.app.discussion:conversation'
class Conversation(Traversable, Persistent, Explicit): class Conversation(Traversable, Persistent, Explicit):
"""A conversation is a container for all comments on a content object. """A conversation is a container for all comments on a content object.

View File

@ -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)

View File

@ -5,7 +5,6 @@ version = '2.4.10.dev0'
install_requires = [ install_requires = [
'setuptools', 'setuptools',
'collective.monkeypatcher',
'plone.app.layout', 'plone.app.layout',
'plone.app.registry', 'plone.app.registry',
'plone.app.uuid', 'plone.app.uuid',