diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index d21438b..c9f9c1a 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """The default comment class and factory. """ from datetime import datetime @@ -47,7 +48,7 @@ except: PLONE_4 = False COMMENT_TITLE = _(u"comment_title", - default=u"${creator} on ${content}") + default=u"${creator} on ${content}") MAIL_NOTIFICATION_MESSAGE = _(u"mail_notification_message", default=u"A comment with the title '${title}' " @@ -118,21 +119,20 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, def Title(self): """The title of the comment. """ - if not self.creator: - creator = _(u"label_anonymous", - default=u"Anonymous") + creator = translate(Message(_(u"label_anonymous", + default=u"Anonymous"))) else: creator = self.creator - + creator = creator.decode("utf-8") + # Fetch the content object (the parent of the comment is the # conversation, the parent of the conversation is the content object). content = aq_base(self.__parent__.__parent__) - title = translate( Message(COMMENT_TITLE, mapping={'creator': creator, - 'content': content.Title()})) + 'content': content.Title().decode("utf-8")})) return title def Creator(self): diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 2cb38a0..61095bb 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import datetime import logging @@ -72,6 +73,16 @@ class CommentTest(PloneTestCase): conversation.addComment(comment1) self.assertEquals("Anonymous on Document 1", comment1.Title()) + def test_title_special_characters(self): + self.portal.invokeFactory(id='doc_sp_chars', + title='Document äüö', + type_name='Document') + conversation = IConversation(self.portal.doc_sp_chars) + comment1 = createObject('plone.Comment') + comment1.creator = "Tarek Ziadé" + conversation.addComment(comment1) + self.assertEquals(u"Tarek Ziadé on Document äüö", comment1.Title()) + def test_creator(self): comment1 = createObject('plone.Comment') comment1.creator = "Jim"