Description index added.
svn path=/plone.app.discussion/trunk/; revision=27251
This commit is contained in:
parent
1340aefe4e
commit
d3ba4f58db
@ -12,6 +12,11 @@ from plone.app.discussion.interfaces import IComment
|
|||||||
def comment_title(object):
|
def comment_title(object):
|
||||||
return object.title
|
return object.title
|
||||||
|
|
||||||
|
@indexer(IComment)
|
||||||
|
def comment_description(object):
|
||||||
|
# Todo: this is wrong!!!
|
||||||
|
return object.title
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def comment_searchable_text(object):
|
def comment_searchable_text(object):
|
||||||
return object.title, object.text
|
return object.title, object.text
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
<!-- adapters for indexes -->
|
<!-- adapters for indexes -->
|
||||||
<adapter name="Title" factory=".catalog.comment_title" />
|
<adapter name="Title" factory=".catalog.comment_title" />
|
||||||
|
<adapter name="Description" factory=".catalog.comment_description" />
|
||||||
<adapter name="SearchableText" factory=".catalog.comment_searchable_text" />
|
<adapter name="SearchableText" factory=".catalog.comment_searchable_text" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
@ -6,11 +6,13 @@ from Products.PloneTestCase.ptc import PloneTestCase
|
|||||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||||
|
|
||||||
from plone.app.discussion.interfaces import IConversation
|
from plone.app.discussion.interfaces import IConversation
|
||||||
|
|
||||||
from plone.indexer import indexer
|
from plone.indexer import indexer
|
||||||
|
from plone.indexer.delegate import DelegatingIndexerFactory
|
||||||
|
|
||||||
from zope.component import provideAdapter
|
from zope.component import provideAdapter
|
||||||
|
|
||||||
from plone.app.discussion.catalog import comment_title, comment_searchable_text
|
from plone.app.discussion.catalog import comment_title, comment_description, comment_searchable_text
|
||||||
|
|
||||||
class IndexersTest(PloneTestCase):
|
class IndexersTest(PloneTestCase):
|
||||||
|
|
||||||
@ -40,7 +42,30 @@ class IndexersTest(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
|
|
||||||
new_id = conversation.addComment(comment)
|
new_id = conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(comment_title(comment)(), 'Comment 1')
|
self.assertEquals(comment_title(comment)(), 'Comment 1')
|
||||||
|
self.assert_(isinstance(comment_title, DelegatingIndexerFactory))
|
||||||
|
|
||||||
|
def test_comment_description(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_description(comment)(), 'Comment 1')
|
||||||
|
self.assert_(isinstance(comment_description, DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_dates(self):
|
def test_dates(self):
|
||||||
# created, modified, effective etc
|
# created, modified, effective etc
|
||||||
@ -64,6 +89,7 @@ class IndexersTest(PloneTestCase):
|
|||||||
new_id = conversation.addComment(comment)
|
new_id = conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(comment_searchable_text(comment)(), ('Comment 1', 'Comment text'))
|
self.assertEquals(comment_searchable_text(comment)(), ('Comment 1', 'Comment text'))
|
||||||
|
self.assert_(isinstance(comment_searchable_text, DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user