From 41010fb32a2ea4c950f6ac88889f21cdfa6bd234 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Thu, 2 Jul 2009 17:50:20 +0000 Subject: [PATCH] fix for "TypeError: can't pickle OIBTreeItems objects". svn path=/plone.app.discussion/trunk/; revision=27778 --- plone/app/discussion/catalog.py | 2 +- plone/app/discussion/conversation.py | 6 +++++- plone/app/discussion/tests/test_conversation.py | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index d45767b..84691c5 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -36,7 +36,7 @@ def last_comment_date(object): @indexer(IContentish, IZCatalog) def commentators(object): conversation = IConversation(object) - return conversation.commentators + return tuple(set(conversation.commentators.keys())) # Comment Indexers diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index b28054f..6fd488f 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -167,7 +167,7 @@ class Conversation(Traversable, Persistent, Explicit): @property def commentators(self): - return self._commentators.keys() + return self._commentators def objectIds(self): return self._comments.keys() @@ -255,6 +255,10 @@ class Conversation(Traversable, Persistent, Explicit): notify(ObjectAddedEvent(comment.__of__(self), self, id)) notify(ContainerModifiedEvent(self)) + # XXX: This shouldn't be necessary. + content_obj = aq_parent(self) + content_obj.reindexObject() + return id # Dict API diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index c8347d0..291e74c 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -422,6 +422,8 @@ class ConversationTest(PloneTestCase): # object, as we just want to check the Conversation object API. conversation = IConversation(self.portal.doc1) + self.assertEquals(conversation.total_comments, 0) + # Add a four comments from three different users # Note: in real life, we always create # comments via the factory to allow different factories to be