Ignore:
Timestamp:
30 Mar 2010, 13:27:36 (15 years ago)
Author:
uli
Message:
  • Fix imports.
  • Add an hurry.query-like query component that supports also retrival of (less expensive to compute) BTree result sets instead of complete lists of ZODB objects.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/catalog.py

    r5007 r5090  
    1 import os
     1"""Components to help cataloging and searching objects.
     2"""
    23import grok
    3 from grok import index
    4 from hurry.query.query import Query, Text
    54from hurry.query import Eq
     5from hurry.query.interfaces import IQuery
     6from hurry.query.query import Query
     7from zope.catalog.catalog import ResultSet
     8from zope.intid.interfaces import IIntIds
     9
    610from waeup.sirp.app import University
    711from waeup.sirp.interfaces import IQueryResultItem
    812from waeup.sirp.student.interfaces import IStudent
     13
     14class WAeUPQuery(Query):
     15     """A hurry.query-like query that supports also ``apply``.
     16     """
     17     grok.implements(IQuery)
     18
     19     def apply(self, query):
     20          """Get a catalog's BTree set of intids conforming to a query.
     21          """
     22          return query.apply()
     23
     24     def searchResults(self, query):
     25          """Get a set of ZODB objects conforming to a query.
     26          """
     27          results = self.apply(query)
     28          if results is not None:
     29               uidutil = getUtility(IIntIds)
     30               results = ResultSet(results, uidutil)
     31          return results
    932
    1033
Note: See TracChangeset for help on using the changeset viewer.