"""Components to help cataloging and searching objects. """ import grok from grok import index from hurry.query import Eq from hurry.query.interfaces import IQuery from hurry.query.query import Query from zope.catalog.catalog import ResultSet from zope.component import getUtility from zope.intid.interfaces import IIntIds from waeup.sirp.app import University from waeup.sirp.interfaces import IQueryResultItem # not yet used class WAeUPQuery(Query): """A hurry.query-like query that supports also ``apply``. """ grok.implements(IQuery) def apply(self, query): """Get a catalog's BTree set of intids conforming to a query. """ return query.apply() def searchResults(self, query): """Get a set of ZODB objects conforming to a query. """ results = self.apply(query) if results is not None: uidutil = getUtility(IIntIds) results = ResultSet(results, uidutil) return results grok.global_utility(WAeUPQuery) # not yet used 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 = ''