From e2934a66b1528d0e98e4e9313b42673d1562b93f Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sat, 4 Jul 2009 16:18:48 +0000 Subject: [PATCH] replace content_object.reindexObject() with event handlers. svn path=/plone.app.discussion/trunk/; revision=27814 --- plone/app/discussion/comment.py | 10 ++++++++-- plone/app/discussion/configure.zcml | 16 ++++++++++++++-- plone/app/discussion/conversation.py | 8 -------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index 943f11e..b6ef470 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -4,7 +4,7 @@ from datetime import datetime from zope.interface import implements from zope.component.factory import Factory -from Acquisition import Implicit +from Acquisition import aq_parent, Implicit from OFS.Traversable import Traversable from AccessControl.Role import RoleManager from AccessControl.Owned import Owned @@ -98,4 +98,10 @@ def notify_workflow(obj, event): """ tool = getToolByName(obj, 'portal_workflow', None) if tool is not None: - tool.notifyCreated(obj) \ No newline at end of file + tool.notifyCreated(obj) + +def notify_content_object(obj, event): + """Tell the content object when a comment is added + """ + content_obj = aq_parent(aq_parent(obj)) + content_obj.reindexObject(idxs=('total_comments', 'last_comment_date', 'commentators',)) \ No newline at end of file diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 10bf672..16bfea8 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -47,6 +47,18 @@ handler=".comment.notify_workflow" /> + + + + - + - + diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index 935229f..02fe54d 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -255,10 +255,6 @@ class Conversation(Traversable, Persistent, Explicit): notify(ObjectAddedEvent(comment.__of__(self), self, id)) notify(ContainerModifiedEvent(self)) - # XXX: This shouldn't be necessary. - content_obj = aq_parent(self) - content_obj.reindexObject() - return id # Dict API @@ -317,10 +313,6 @@ class Conversation(Traversable, Persistent, Explicit): if not suppress_container_modified: notify(ContainerModifiedEvent(self)) - # XXX: This shouldn't be necessary. - content_obj = aq_parent(self) - content_obj.reindexObject() - def __iter__(self): return iter(self._comments)