plone.app.discussion/plone/app/discussion/events.py
Alin Voinea 14d4382ca6 Use commented object as context instead of comment within event trigger
- In order this to work with plone.contentrules use commented object as
  the main context within custom discussion events and add comment as the
  second parameter.
2014-04-18 16:33:12 +03:00

40 lines
1.2 KiB
Python

""" Custom discussion events
"""
from zope.interface import implements
from plone.app.discussion.interfaces import IDiscussionEvent
from plone.app.discussion.interfaces import ICommentAddedEvent
from plone.app.discussion.interfaces import ICommentRemovedEvent
from plone.app.discussion.interfaces import IReplyAddedEvent
from plone.app.discussion.interfaces import IReplyRemovedEvent
class DiscussionEvent(object):
""" Custom event
"""
implements(IDiscussionEvent)
def __init__(self, context, comment, **kwargs):
self.object = context
self.comment = comment
for key, value in kwargs.items():
setattr(self, key, value)
class CommentAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is added
"""
implements(ICommentAddedEvent)
class CommentRemovedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is removed
"""
implements(ICommentRemovedEvent)
class ReplyAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment reply is added
"""
implements(IReplyAddedEvent)
class ReplyRemovedEvent(DiscussionEvent):
""" Event to be triggered when a Comment reply is removed
"""
implements(IReplyRemovedEvent)