From e12d19a6e98fd1764e650d219a4c9891e5fded88 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sat, 28 Aug 2010 16:07:44 +0000 Subject: [PATCH] Fix bugs that have been introduced with the latest pylint "optimizations". svn path=/plone.app.discussion/trunk/; revision=39269 --- plone/app/discussion/comment.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index 5725d1d..38eaa89 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -11,6 +11,8 @@ from zope.interface import implements from Acquisition import aq_parent, Implicit +from string import Template + from AccessControl.Role import RoleManager from AccessControl.Owned import Owned @@ -41,11 +43,8 @@ except: from OFS.Traversable import Traversable as WorkflowAware PLONE_4 = False -USER_NOTIFICATION_MESSAGE = "A comment with the title '%s' has been posted ", \ - "here: %s" - -MODERATOR_NOTIFICATION_MESSAGE = "A comment with the title '%s' has been ", \ - "posted here: %s" +MAIL_NOTIFICATION_MESSAGE = Template("A comment with the title '%title' " + "has been posted here: %link") class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, @@ -136,14 +135,14 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, CommentFactory = Factory(Comment) -def notify_workflow(obj): +def notify_workflow(obj, event): """Tell the workflow tool when a comment is added """ tool = getToolByName(obj, 'portal_workflow', None) if tool is not None: tool.notifyCreated(obj) -def notify_content_object(obj): +def notify_content_object(obj, event): """Tell the content object when a comment is added """ content_obj = aq_parent(aq_parent(obj)) @@ -151,7 +150,7 @@ def notify_content_object(obj): 'last_comment_date', 'commentators',)) -def notify_content_object_deleted(obj): +def notify_content_object_deleted(obj, event): """Remove all comments of a content object when the content object has been deleted. """ @@ -160,7 +159,7 @@ def notify_content_object_deleted(obj): for comment in conversation.getComments(): del conversation[comment.id] -def notify_user(obj): +def notify_user(obj, event): """Tell users when a comment has been added. This method composes and sends emails to all users that have added a @@ -195,11 +194,12 @@ def notify_user(obj): if obj != comment and \ comment.author_notification and comment.author_email: subject = "A comment has been posted." - message = USER_NOTIFICATION_MESSAGE % (obj.title, - content_object.absolute_url(),) + message = MAIL_NOTIFICATION_MESSAGE.substitute( + title=obj.title, + link=content_object.absolute_url()) mail_host.send(message, comment.author_email, sender, subject) -def notify_moderator(obj): +def notify_moderator(obj, event): """Tell the moderator when a comment needs attention. This method sends an email to the site admin (mail control panel setting) @@ -240,9 +240,9 @@ def notify_moderator(obj): # Compose email #comment = conversation.getComments().next() subject = "A comment has been posted." - message = MODERATOR_NOTIFICATION_MESSAGE \ - % (obj.title, - content_object.absolute_url(),) + message = MAIL_NOTIFICATION_MESSAGE.substitute( + title=obj.title, + link=content_object.absolute_url()) # Send email if PLONE_4: