diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index 03441c4..31fdcbd 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -16,6 +16,11 @@ from plone.app.discussion.interfaces import IConversation, IComment from plone.indexer import indexer +try: + from plone.uuid.interfaces import IUUID +except ImportError: + IUUID = None + MAX_DESCRIPTION = 25 # Conversation Indexers @@ -130,3 +135,9 @@ def comments_last_comment_date(object): @indexer(IComment) def comments_commentators(object): return None + +# Make sure comments don't inherit their container's UID +@indexer(IComment) +def UID(object): + if IUUID: + return IUUID(object, None) diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index f72c5c9..a3afbca 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -101,6 +101,7 @@ + diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 52cc63b..bd0b164 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -71,27 +71,36 @@ class CommentTest(PloneTestCase): conversation.addComment(comment1) comment_brain = self.catalog.searchResults( portal_type = 'Discussion Item')[0] - self.failUnless(comment_brain.UID) + + # comment should only have a UID if plone.uuid is present + try: + from plone.uuid.interfaces import IUUID + IUUID # pyflakes + except ImportError: + self.failIf(comment_brain.UID) + else: + self.failUnless(comment_brain.UID) def test_uid_is_unique(self): - conversation = IConversation(self.portal.doc1) + 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) + + # make sure uids are either both None (i.e. without plone.uuid), + # or not equal + if brains[0].UID != None or 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) + 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): diff --git a/setup.py b/setup.py index 7459942..43c5255 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,33 @@ +import sys from setuptools import setup, find_packages version = '1.0bRC1' +install_requires = [ + 'setuptools', + 'collective.autopermission', + 'collective.monkeypatcher', + 'plone.app.layout', + 'plone.app.registry', + 'plone.app.z3cform', + 'plone.indexer', + 'plone.registry', + 'plone.z3cform', + 'ZODB3', + 'zope.interface', + 'zope.component', + 'zope.annotation', + 'zope.event', + 'zope.container', + 'zope.lifecycleevent', + 'zope.site', + 'z3c.form>=2.3.3', + ] + +# On Python 2.6 (implying Plone 4), require plone.app.uuid +if sys.version_info >= (2,6): + install_requires.append('plone.app.uuid') + setup(name='plone.app.discussion', version=version, description="Enhanced discussion support for Plone", @@ -20,27 +46,7 @@ setup(name='plone.app.discussion', namespace_packages=['plone', 'plone.app'], include_package_data=True, zip_safe=False, - install_requires=[ - 'setuptools', - 'collective.autopermission', - 'collective.monkeypatcher', - 'plone.app.layout', - 'plone.app.registry', - 'plone.app.uuid', - 'plone.app.z3cform', - 'plone.indexer', - 'plone.registry', - 'plone.z3cform', - 'ZODB3', - 'zope.interface', - 'zope.component', - 'zope.annotation', - 'zope.event', - 'zope.container', - 'zope.lifecycleevent', - 'zope.site', - 'z3c.form>=2.3.3', - ], + install_requires=install_requires, extras_require = { 'test': [ 'plone.app.testing',