replace content_object.reindexObject() with event handlers.
svn path=/plone.app.discussion/trunk/; revision=27814
This commit is contained in:
parent
2031ec67cf
commit
e2934a66b1
@ -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
|
||||
@ -99,3 +99,9 @@ def notify_workflow(obj, event):
|
||||
tool = getToolByName(obj, 'portal_workflow', None)
|
||||
if tool is not None:
|
||||
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',))
|
@ -47,6 +47,18 @@
|
||||
handler=".comment.notify_workflow"
|
||||
/>
|
||||
|
||||
<subscriber
|
||||
for="plone.app.discussion.interfaces.IComment
|
||||
zope.app.container.contained.IObjectAddedEvent"
|
||||
handler=".comment.notify_content_object"
|
||||
/>
|
||||
|
||||
<subscriber
|
||||
for="plone.app.discussion.interfaces.IComment
|
||||
zope.app.container.contained.IObjectRemovedEvent"
|
||||
handler=".comment.notify_content_object"
|
||||
/>
|
||||
|
||||
<subscriber
|
||||
for="plone.app.discussion.interfaces.IComment
|
||||
zope.app.container.contained.IObjectAddedEvent"
|
||||
@ -59,13 +71,13 @@
|
||||
handler=".tool.unindex_object"
|
||||
/>
|
||||
|
||||
<!-- conversation indexes -->
|
||||
<!-- Conversation indexes -->
|
||||
<adapter name="total_comments" factory=".catalog.total_comments" />
|
||||
<adapter name="last_comment_date" factory=".catalog.last_comment_date" />
|
||||
<adapter name="commentators" factory=".catalog.commentators" />
|
||||
<adapter name="in_response_to" factory=".catalog.in_response_to" />
|
||||
|
||||
<!-- comment indexes -->
|
||||
<!-- Comment indexes -->
|
||||
<adapter name="Title" factory=".catalog.title" />
|
||||
<adapter name="Creator" factory=".catalog.creator" />
|
||||
<adapter name="Description" factory=".catalog.description" />
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user