Make pylint happy.

svn path=/plone.app.discussion/trunk/; revision=39265
This commit is contained in:
Timo Stollenwerk 2010-08-28 15:35:21 +00:00
parent 487d5308a5
commit 9264d2d42d

View File

@ -41,6 +41,12 @@ 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 ", \
"here: %s"
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,
RoleManager, Owned, Implicit, Persistent): RoleManager, Owned, Implicit, Persistent):
@ -130,14 +136,14 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
CommentFactory = Factory(Comment) CommentFactory = Factory(Comment)
def notify_workflow(obj, event): def notify_workflow(obj):
"""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, event): def notify_content_object(obj):
"""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))
@ -145,7 +151,7 @@ def notify_content_object(obj, event):
'last_comment_date', 'last_comment_date',
'commentators',)) 'commentators',))
def notify_content_object_deleted(obj, event): def notify_content_object_deleted(obj):
"""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.
""" """
@ -154,7 +160,7 @@ def notify_content_object_deleted(obj, event):
for comment in conversation.getComments(): for comment in conversation.getComments():
del conversation[comment.id] del conversation[comment.id]
def notify_user(obj, event): def notify_user(obj):
"""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
@ -187,15 +193,13 @@ def notify_user(obj, event):
for comment in conversation.getComments(): for comment in conversation.getComments():
if obj != comment and \ if obj != comment and \
comment.author_notification and \ comment.author_notification and comment.author_email:
comment.author_email: subject = "A comment has been posted."
subject = "A comment has been posted." message = USER_NOTIFICATION_MESSAGE % (obj.title,
message = "A comment with the title '%s' has been posted here: %s" \ content_object.absolute_url(),)
% (obj.title, mail_host.send(message, comment.author_email, sender, subject)
content_object.absolute_url(),)
mail_host.send(message, comment.author_email, sender, subject)
def notify_moderator(obj, index): def notify_moderator(obj):
"""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)
@ -234,9 +238,9 @@ def notify_moderator(obj, index):
content_object = aq_parent(conversation) content_object = aq_parent(conversation)
# 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 = "A comment with the title '%s' has been posted here: %s" \ message = MODERATOR_NOTIFICATION_MESSAGE \
% (obj.title, % (obj.title,
content_object.absolute_url(),) content_object.absolute_url(),)