Fix bugs that have been introduced with the latest pylint "optimizations".

svn path=/plone.app.discussion/trunk/; revision=39269
This commit is contained in:
Timo Stollenwerk 2010-08-28 16:07:44 +00:00
parent 9264d2d42d
commit e12d19a6e9
1 changed files with 15 additions and 15 deletions

View File

@ -11,6 +11,8 @@ from zope.interface import implements
from Acquisition import aq_parent, Implicit from Acquisition import aq_parent, Implicit
from string import Template
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
from AccessControl.Owned import Owned from AccessControl.Owned import Owned
@ -41,11 +43,8 @@ except:
from OFS.Traversable import Traversable as WorkflowAware from OFS.Traversable import Traversable as WorkflowAware
PLONE_4 = False PLONE_4 = False
USER_NOTIFICATION_MESSAGE = "A comment with the title '%s' has been posted ", \ MAIL_NOTIFICATION_MESSAGE = Template("A comment with the title '%title' "
"here: %s" "has been posted here: %link")
MODERATOR_NOTIFICATION_MESSAGE = "A comment with the title '%s' has been ", \
"posted here: %s"
class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
@ -136,14 +135,14 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
CommentFactory = Factory(Comment) CommentFactory = Factory(Comment)
def notify_workflow(obj): def notify_workflow(obj, event):
"""Tell the workflow tool when a comment is added """Tell the workflow tool when a comment is added
""" """
tool = getToolByName(obj, 'portal_workflow', None) tool = getToolByName(obj, 'portal_workflow', None)
if tool is not None: if tool is not None:
tool.notifyCreated(obj) tool.notifyCreated(obj)
def notify_content_object(obj): def notify_content_object(obj, event):
"""Tell the content object when a comment is added """Tell the content object when a comment is added
""" """
content_obj = aq_parent(aq_parent(obj)) content_obj = aq_parent(aq_parent(obj))
@ -151,7 +150,7 @@ def notify_content_object(obj):
'last_comment_date', 'last_comment_date',
'commentators',)) '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 """Remove all comments of a content object when the content object has been
deleted. deleted.
""" """
@ -160,7 +159,7 @@ def notify_content_object_deleted(obj):
for comment in conversation.getComments(): for comment in conversation.getComments():
del conversation[comment.id] del conversation[comment.id]
def notify_user(obj): def notify_user(obj, event):
"""Tell users when a comment has been added. """Tell users when a comment has been added.
This method composes and sends emails to all users that have added a 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 \ if obj != comment and \
comment.author_notification and comment.author_email: comment.author_notification and comment.author_email:
subject = "A comment has been posted." subject = "A comment has been posted."
message = USER_NOTIFICATION_MESSAGE % (obj.title, message = MAIL_NOTIFICATION_MESSAGE.substitute(
content_object.absolute_url(),) title=obj.title,
link=content_object.absolute_url())
mail_host.send(message, comment.author_email, sender, subject) 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. """Tell the moderator when a comment needs attention.
This method sends an email to the site admin (mail control panel setting) This method sends an email to the site admin (mail control panel setting)
@ -240,9 +240,9 @@ def notify_moderator(obj):
# Compose email # Compose email
#comment = conversation.getComments().next() #comment = conversation.getComments().next()
subject = "A comment has been posted." subject = "A comment has been posted."
message = MODERATOR_NOTIFICATION_MESSAGE \ message = MAIL_NOTIFICATION_MESSAGE.substitute(
% (obj.title, title=obj.title,
content_object.absolute_url(),) link=content_object.absolute_url())
# Send email # Send email
if PLONE_4: if PLONE_4: