diff --git a/CHANGES.txt b/CHANGES.txt index 3d64c0c..20142a1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 1.0RC1 (unreleased) ------------------- +- Make sure comment UIDs in the catalog are always unique. This fixes + http://dev.plone.org/plone/ticket/10652. + [timo] + - Fix 'check all' on batch moderation page. [davisagli] diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index e7b9d2f..ef2b4e6 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -10,7 +10,9 @@ - + + + @@ -43,6 +45,7 @@ + diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index 1887e9e..52936dd 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -41,6 +41,7 @@ from zope.container.contained import ContainerModifiedEvent try: # Plone 4 from zope.lifecycleevent import ObjectAddedEvent + from zope.lifecycleevent import ObjectCreatedEvent from zope.lifecycleevent import ObjectRemovedEvent except ImportError: # pragma: no cover # Plone 3.x @@ -252,6 +253,7 @@ class Conversation(Traversable, Persistent, Explicit): # Notify that the object is added. The object must here be # acquisition wrapped or the indexing will fail. + notify(ObjectCreatedEvent(comment)) notify(ObjectAddedEvent(comment.__of__(self), self, id)) notify(ContainerModifiedEvent(self)) diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index cc115a1..52cc63b 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -9,6 +9,8 @@ from zope.component import createObject from zope.component import getMultiAdapter +from Products.CMFCore.utils import getToolByName + from Products.PloneTestCase.ptc import PloneTestCase from plone.app.discussion.tests.layer import DiscussionLayer @@ -32,7 +34,10 @@ class CommentTest(PloneTestCase): self.portal.invokeFactory(id='doc1', title='Document 1', type_name='Document') - + self.catalog = getToolByName(self.portal, 'portal_catalog') + self.document_brain = self.catalog.searchResults( + portal_type = 'Document')[0] + def test_factory(self): comment1 = createObject('plone.Comment') self.assert_(IComment.providedBy(comment1)) @@ -60,6 +65,35 @@ class CommentTest(PloneTestCase): self.assertEquals('123', comment1.getId()) self.assertEquals(u'123', comment1.__name__) + def test_uid(self): + conversation = IConversation(self.portal.doc1) + comment1 = createObject('plone.Comment') + conversation.addComment(comment1) + comment_brain = self.catalog.searchResults( + portal_type = 'Discussion Item')[0] + self.failUnless(comment_brain.UID) + + def test_uid_is_unique(self): + conversation = IConversation(self.portal.doc1) + comment1 = createObject('plone.Comment') + conversation.addComment(comment1) + comment2 = createObject('plone.Comment') + conversation.addComment(comment2) + brains = self.catalog.searchResults( + portal_type = 'Discussion Item') + self.assertNotEquals(brains[0].UID, None) + self.assertNotEquals(brains[1].UID, None) + self.assertNotEquals(brains[0].UID, brains[1].UID) + + def test_comment_uid_differs_from_content_uid(self): + conversation = IConversation(self.portal.doc1) + comment1 = createObject('plone.Comment') + conversation.addComment(comment1) + comment_brain = self.catalog.searchResults( + portal_type = 'Discussion Item')[0] + self.assertNotEquals(comment_brain.UID, None) + self.assertNotEquals(self.document_brain.UID, comment_brain.UID) + def test_title(self): conversation = IConversation(self.portal.doc1) comment1 = createObject('plone.Comment') diff --git a/setup.py b/setup.py index e9278dc..4aa9b65 100644 --- a/setup.py +++ b/setup.py @@ -26,9 +26,11 @@ setup(name='plone.app.discussion', 'collective.monkeypatcher', 'plone.app.layout', 'plone.app.registry', + 'plone.app.uuid', 'plone.app.z3cform', 'plone.indexer', 'plone.registry', + 'plone.uuid', 'plone.z3cform', 'ZODB3', 'zope.interface',