import os import grok from grok import index from hurry.query.query import Query, Text from hurry.query import Eq from waeup.sirp.app import University from waeup.sirp.interfaces import IQueryResultItem from waeup.sirp.student.interfaces import IStudent class StudentIndexes(grok.Indexes): grok.site(University) grok.name('students_catalog') grok.context(IStudent) name = grok.index.Field(attribute='name') class QueryResultItem(object): grok.implements(IQueryResultItem) url = None title = None description = None def __init__(self, context, view): self.context = context self.url = view.url(context) self.title = context.title self.description = '' def search_context(query): result = Query().searchResults( Eq(('students_catalog', 'name'), query) ) return result