creator index added.

svn path=/plone.app.discussion/trunk/; revision=27258
This commit is contained in:
Timo Stollenwerk 2009-06-01 23:29:09 +00:00
parent 04bed35357
commit dc948da00b
3 changed files with 24 additions and 1 deletions

View File

@ -18,6 +18,10 @@ MAX_DESCRIPTION=25
def comment_title(object): def comment_title(object):
return object.title return object.title
@indexer(IComment)
def comment_creator(object):
return object.creator
@indexer(IComment) @indexer(IComment)
def comment_description(object): def comment_description(object):
# Return the first 25 words of the comment text and append '...' # Return the first 25 words of the comment text and append '...'

View File

@ -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="Creator" factory=".catalog.comment_creator" />
<adapter name="Description" factory=".catalog.comment_description" /> <adapter name="Description" factory=".catalog.comment_description" />
<adapter name="SearchableText" factory=".catalog.comment_searchable_text" /> <adapter name="SearchableText" factory=".catalog.comment_searchable_text" />
<adapter name="effective" factory=".catalog.effective" /> <adapter name="effective" factory=".catalog.effective" />

View File

@ -118,7 +118,25 @@ class IndexersTest(PloneTestCase):
self.assert_(isinstance(catalog.comment_searchable_text, DelegatingIndexerFactory)) self.assert_(isinstance(catalog.comment_searchable_text, DelegatingIndexerFactory))
def test_creator(self): def test_creator(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'
comment.creator = "Jim"
new_id = conversation.addComment(comment)
self.assertEquals(catalog.comment_creator(comment)(), ('Jim'))
def test_title(self): def test_title(self):
pass pass