Make sure comment UIDs in the catalog are always unique. This fixes

http://dev.plone.org/plone/ticket/10652. We depend on plone.uuid and plone.app.uuid now. Refs #10652.

svn path=/plone.app.discussion/trunk/; revision=46005
This commit is contained in:
Timo Stollenwerk 2010-11-28 11:39:19 +00:00
parent 664e5c273e
commit ac4a64f55d
5 changed files with 47 additions and 2 deletions

View File

@ -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]

View File

@ -10,7 +10,9 @@
<five:registerPackage package="." />
<include package="plone.indexer" />
<include package="plone.uuid" />
<include package="plone.app.uuid" />
<include file="permissions.zcml" />
<include file="notifications.zcml" />
<include file="subscribers.zcml" />
@ -43,6 +45,7 @@
<!-- Comments -->
<class class=".comment.Comment">
<implements interface="plone.uuid.interfaces.IAttributeUUID" />
<require interface=".interfaces.IComment" permission="zope2.View" />
<require attributes="Title Creator getId getText" permission="zope2.View" />
</class>

View File

@ -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))

View File

@ -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')

View File

@ -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',