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:
parent
664e5c273e
commit
ac4a64f55d
@ -4,6 +4,10 @@ Changelog
|
|||||||
1.0RC1 (unreleased)
|
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.
|
- Fix 'check all' on batch moderation page.
|
||||||
[davisagli]
|
[davisagli]
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
<five:registerPackage package="." />
|
<five:registerPackage package="." />
|
||||||
|
|
||||||
<include package="plone.indexer" />
|
<include package="plone.indexer" />
|
||||||
|
<include package="plone.uuid" />
|
||||||
|
<include package="plone.app.uuid" />
|
||||||
|
|
||||||
<include file="permissions.zcml" />
|
<include file="permissions.zcml" />
|
||||||
<include file="notifications.zcml" />
|
<include file="notifications.zcml" />
|
||||||
<include file="subscribers.zcml" />
|
<include file="subscribers.zcml" />
|
||||||
@ -43,6 +45,7 @@
|
|||||||
<!-- Comments -->
|
<!-- Comments -->
|
||||||
|
|
||||||
<class class=".comment.Comment">
|
<class class=".comment.Comment">
|
||||||
|
<implements interface="plone.uuid.interfaces.IAttributeUUID" />
|
||||||
<require interface=".interfaces.IComment" permission="zope2.View" />
|
<require interface=".interfaces.IComment" permission="zope2.View" />
|
||||||
<require attributes="Title Creator getId getText" permission="zope2.View" />
|
<require attributes="Title Creator getId getText" permission="zope2.View" />
|
||||||
</class>
|
</class>
|
||||||
|
@ -41,6 +41,7 @@ from zope.container.contained import ContainerModifiedEvent
|
|||||||
try:
|
try:
|
||||||
# Plone 4
|
# Plone 4
|
||||||
from zope.lifecycleevent import ObjectAddedEvent
|
from zope.lifecycleevent import ObjectAddedEvent
|
||||||
|
from zope.lifecycleevent import ObjectCreatedEvent
|
||||||
from zope.lifecycleevent import ObjectRemovedEvent
|
from zope.lifecycleevent import ObjectRemovedEvent
|
||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
# Plone 3.x
|
# Plone 3.x
|
||||||
@ -252,6 +253,7 @@ class Conversation(Traversable, Persistent, Explicit):
|
|||||||
|
|
||||||
# Notify that the object is added. The object must here be
|
# Notify that the object is added. The object must here be
|
||||||
# acquisition wrapped or the indexing will fail.
|
# acquisition wrapped or the indexing will fail.
|
||||||
|
notify(ObjectCreatedEvent(comment))
|
||||||
notify(ObjectAddedEvent(comment.__of__(self), self, id))
|
notify(ObjectAddedEvent(comment.__of__(self), self, id))
|
||||||
notify(ContainerModifiedEvent(self))
|
notify(ContainerModifiedEvent(self))
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ from zope.component import createObject
|
|||||||
|
|
||||||
from zope.component import getMultiAdapter
|
from zope.component import getMultiAdapter
|
||||||
|
|
||||||
|
from Products.CMFCore.utils import getToolByName
|
||||||
|
|
||||||
from Products.PloneTestCase.ptc import PloneTestCase
|
from Products.PloneTestCase.ptc import PloneTestCase
|
||||||
|
|
||||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||||
@ -32,7 +34,10 @@ class CommentTest(PloneTestCase):
|
|||||||
self.portal.invokeFactory(id='doc1',
|
self.portal.invokeFactory(id='doc1',
|
||||||
title='Document 1',
|
title='Document 1',
|
||||||
type_name='Document')
|
type_name='Document')
|
||||||
|
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||||
|
self.document_brain = self.catalog.searchResults(
|
||||||
|
portal_type = 'Document')[0]
|
||||||
|
|
||||||
def test_factory(self):
|
def test_factory(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
self.assert_(IComment.providedBy(comment1))
|
self.assert_(IComment.providedBy(comment1))
|
||||||
@ -60,6 +65,35 @@ class CommentTest(PloneTestCase):
|
|||||||
self.assertEquals('123', comment1.getId())
|
self.assertEquals('123', comment1.getId())
|
||||||
self.assertEquals(u'123', comment1.__name__)
|
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):
|
def test_title(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
|
2
setup.py
2
setup.py
@ -26,9 +26,11 @@ setup(name='plone.app.discussion',
|
|||||||
'collective.monkeypatcher',
|
'collective.monkeypatcher',
|
||||||
'plone.app.layout',
|
'plone.app.layout',
|
||||||
'plone.app.registry',
|
'plone.app.registry',
|
||||||
|
'plone.app.uuid',
|
||||||
'plone.app.z3cform',
|
'plone.app.z3cform',
|
||||||
'plone.indexer',
|
'plone.indexer',
|
||||||
'plone.registry',
|
'plone.registry',
|
||||||
|
'plone.uuid',
|
||||||
'plone.z3cform',
|
'plone.z3cform',
|
||||||
'ZODB3',
|
'ZODB3',
|
||||||
'zope.interface',
|
'zope.interface',
|
||||||
|
Loading…
Reference in New Issue
Block a user