From a946fb54faaf8cf5efbd3e46fe4e747e2bef9bbe Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 6 Jul 2009 16:56:09 +0000 Subject: [PATCH] indexes for IComment added to override the IConversation indexes. svn path=/plone.app.discussion/trunk/; revision=27838 --- plone/app/discussion/catalog.py | 20 ++++++++++++++++---- plone/app/discussion/configure.zcml | 3 +++ plone/app/discussion/tests/test_catalog.py | 11 +++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index 9f69ae0..8651255 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -12,17 +12,15 @@ from Products.CMFCore.interfaces import IContentish from Products.ZCatalog.interfaces import IZCatalog -from plone.indexer import indexer - from plone.app.discussion.interfaces import IConversation, IComment +from plone.indexer import indexer +from plone.indexer.interfaces import IIndexer MAX_DESCRIPTION=25 # Conversation Indexers -from plone.indexer.interfaces import IIndexer - @indexer(IContentish, IZCatalog) def total_comments(object): conversation = IConversation(object) @@ -89,3 +87,17 @@ def modified(object): object.modification_date.hour, object.modification_date.minute, object.modification_date.second) + +# Override the conversation indexers for comments + +@indexer(IComment) +def comments_total_comments(object): + return None + +@indexer(IComment) +def comments_last_comment_date(object): + return None + +@indexer(IComment) +def comments_commentators(object): + return None diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 16bfea8..4c5e1d0 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -85,5 +85,8 @@ + + + diff --git a/plone/app/discussion/tests/test_catalog.py b/plone/app/discussion/tests/test_catalog.py index aa0ff71..fb4ccc0 100644 --- a/plone/app/discussion/tests/test_catalog.py +++ b/plone/app/discussion/tests/test_catalog.py @@ -64,6 +64,7 @@ class ConversationCatalogTest(PloneTestCase): path = {'query' : '/'.join(self.portal.doc1.getPhysicalPath()) }, portal_type = "Document" ) + self.brains = brains self.conversation = conversation self.conversation_brain = brains[0] self.comment1 = comment1 @@ -171,6 +172,16 @@ class ConversationCatalogTest(PloneTestCase): conversation_brain = brains[0] self.assertEquals(conversation_brain.commentators, ()) + def test_conversation_indexes_not_in_comments(self): + brains = self.catalog.searchResults( + path = {'query' : '/'.join(self.portal.doc1.getPhysicalPath()) }, + portal_type = "Discussion Item" + ) + comment1_brain = brains[0] + self.assertEquals(comment1_brain.commentators, None) + self.assertEquals(comment1_brain.last_comment_date, None) + self.assertEquals(comment1_brain.total_comments, None) + class CommentCatalogTest(PloneTestCase): layer = DiscussionLayer