make sure comments don't get indexed with their parents' UID in Plone 3. only declare dependency on plone.app.uuid in Python 2.6, since we only use it in Plone 4 currently.
svn path=/plone.app.discussion/trunk/; revision=46353
This commit is contained in:
parent
b9d929bca3
commit
0cb75778ba
@ -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)
|
||||
|
@ -101,6 +101,7 @@
|
||||
<adapter name="in_response_to" factory=".catalog.in_response_to" />
|
||||
|
||||
<!-- Comment indexes -->
|
||||
<adapter name="UID" factory=".catalog.UID" />
|
||||
<adapter name="Title" factory=".catalog.title" />
|
||||
<adapter name="Creator" factory=".catalog.creator" />
|
||||
<adapter name="Description" factory=".catalog.description" />
|
||||
|
@ -71,7 +71,15 @@ 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)
|
||||
@ -81,9 +89,11 @@ class CommentTest(PloneTestCase):
|
||||
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)
|
||||
@ -91,7 +101,6 @@ class CommentTest(PloneTestCase):
|
||||
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):
|
||||
|
48
setup.py
48
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',
|
||||
|
Loading…
Reference in New Issue
Block a user