diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py
index 9bd9237..3a5ac3b 100644
--- a/plone/app/discussion/catalog.py
+++ b/plone/app/discussion/catalog.py
@@ -4,3 +4,19 @@ indexes with values based on the IComment interface.
Also provide event handlers to actually catalog the comments.
"""
+from plone.indexer import indexer
+
+from plone.app.discussion.interfaces import IComment
+
+@indexer(IComment)
+def comment_title(object):
+ return object.title
+
+@indexer(IComment)
+def comment_text(object):
+ return object.text
+
+@indexer(IComment)
+def comment_searchable_text(object):
+ return object.title, object.text
+
diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml
index 491d18d..f2d3e27 100644
--- a/plone/app/discussion/configure.zcml
+++ b/plone/app/discussion/configure.zcml
@@ -57,4 +57,9 @@
handler=".tool.unindex_object"
/>
+
+
+
+
+
diff --git a/plone/app/discussion/tests/test_indexers.py b/plone/app/discussion/tests/test_indexers.py
index d2b9235..fd91684 100644
--- a/plone/app/discussion/tests/test_indexers.py
+++ b/plone/app/discussion/tests/test_indexers.py
@@ -1,42 +1,106 @@
import unittest
+from zope.component import createObject
+
from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer
-class TestIndexers(PloneTestCase):
-
- layer = DiscussionLayer
-
- def test_title(self):
- pass
+from plone.app.discussion.interfaces import IConversation
+from plone.indexer import indexer
+
+from zope.component import provideAdapter
+
+from plone.app.discussion.catalog import comment_title, comment_text, comment_searchable_text
+
+class IndexersTest(PloneTestCase):
+
+ layer = DiscussionLayer
+
+ def afterSetUp(self):
+ # First we need to create some content.
+ self.loginAsPortalOwner()
+ typetool = self.portal.portal_types
+ typetool.constructContent('Document', self.portal, 'doc1')
+ provideAdapter(comment_title, name='title')
+
+ def test_comment_title(self):
+
+ # Create a conversation. In this case we doesn't assign it to an
+ # object, as we just want to check the Conversation object API.
+ conversation = IConversation(self.portal.doc1)
+
+ # Pretend that we have traversed to the comment by aq wrapping it.
+ conversation = conversation.__of__(self.portal.doc1)
+
+ # Add a comment. Note: in real life, we always create comments via the factory
+ # to allow different factories to be swapped in
+
+ comment = createObject('plone.Comment')
+ comment.title = 'Comment 1'
+ comment.text = 'Comment text'
+
+ new_id = conversation.addComment(comment)
+ self.assertEquals(comment_title(comment)(), 'Comment 1')
+
+ def test_comment_text(self):
+ # Create a conversation. In this case we doesn't assign it to an
+ # object, as we just want to check the Conversation object API.
+ conversation = IConversation(self.portal.doc1)
+
+ # Pretend that we have traversed to the comment by aq wrapping it.
+ conversation = conversation.__of__(self.portal.doc1)
+
+ # Add a comment. Note: in real life, we always create comments via the factory
+ # to allow different factories to be swapped in
+
+ comment = createObject('plone.Comment')
+ comment.title = 'Comment 1'
+ comment.text = 'Comment text'
+
+ new_id = conversation.addComment(comment)
+
+ self.assertEquals(comment_text(comment)(), 'Comment text')
- def test_description(self):
- pass
-
def test_dates(self):
# created, modified, effective etc
pass
def test_searchable_text(self):
- pass
+ # Create a conversation. In this case we doesn't assign it to an
+ # object, as we just want to check the Conversation object API.
+ conversation = IConversation(self.portal.doc1)
+
+ # Pretend that we have traversed to the comment by aq wrapping it.
+ conversation = conversation.__of__(self.portal.doc1)
+
+ # Add a comment. Note: in real life, we always create comments via the factory
+ # to allow different factories to be swapped in
+
+ comment = createObject('plone.Comment')
+ comment.title = 'Comment 1'
+ comment.text = 'Comment text'
+
+ new_id = conversation.addComment(comment)
+
+ self.assertEquals(comment_searchable_text(comment)(), ('Comment 1', 'Comment text'))
def test_creator(self):
pass
def test_title(self):
pass
-
+
def test_in_reply_to(self):
pass
-
+
def test_path(self):
pass
-
+
def test_review_state(self):
pass
-
+
def test_object_provides(self):
pass
-
+
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)
\ No newline at end of file
diff --git a/setup.py b/setup.py
index d2abc3b..2e568ca 100644
--- a/setup.py
+++ b/setup.py
@@ -34,6 +34,7 @@ setup(name='plone.app.discussion',
'zope.annotation',
'zope.event',
'zope.app.container', # XXX: eventually should change to zope.container
+ 'plone.indexer',
],
entry_points="""
[z3c.autoinclude.plugin]