Last change
on this file since 6551 was
6447,
checked in by Henrik Bettermann, 13 years ago
|
Implement search function for academic section. The courses_catalog and the certcourses_catalog are searched.
Remove search pages for students. Student search will be done in the upcoming student package.
|
-
Property svn:eol-style set to
native
|
File size:
1.3 KB
|
Rev | Line | |
---|
[5090] | 1 | """Components to help cataloging and searching objects. |
---|
| 2 | """ |
---|
[3521] | 3 | import grok |
---|
[5091] | 4 | from grok import index |
---|
[3521] | 5 | from hurry.query import Eq |
---|
[5090] | 6 | from hurry.query.interfaces import IQuery |
---|
| 7 | from hurry.query.query import Query |
---|
| 8 | from zope.catalog.catalog import ResultSet |
---|
[5091] | 9 | from zope.component import getUtility |
---|
[5090] | 10 | from zope.intid.interfaces import IIntIds |
---|
| 11 | |
---|
[4920] | 12 | from waeup.sirp.app import University |
---|
[5007] | 13 | from waeup.sirp.interfaces import IQueryResultItem |
---|
[3521] | 14 | |
---|
[6447] | 15 | # not yet used |
---|
[5090] | 16 | class WAeUPQuery(Query): |
---|
[6207] | 17 | """A hurry.query-like query that supports also ``apply``. |
---|
| 18 | """ |
---|
| 19 | grok.implements(IQuery) |
---|
[4789] | 20 | |
---|
[6207] | 21 | def apply(self, query): |
---|
| 22 | """Get a catalog's BTree set of intids conforming to a query. |
---|
| 23 | """ |
---|
| 24 | return query.apply() |
---|
[5090] | 25 | |
---|
[6207] | 26 | def searchResults(self, query): |
---|
| 27 | """Get a set of ZODB objects conforming to a query. |
---|
| 28 | """ |
---|
| 29 | results = self.apply(query) |
---|
| 30 | if results is not None: |
---|
| 31 | uidutil = getUtility(IIntIds) |
---|
| 32 | results = ResultSet(results, uidutil) |
---|
| 33 | return results |
---|
[5090] | 34 | |
---|
[5091] | 35 | grok.global_utility(WAeUPQuery) |
---|
[5090] | 36 | |
---|
[6447] | 37 | # not yet used |
---|
[4789] | 38 | class QueryResultItem(object): |
---|
[6207] | 39 | grok.implements(IQueryResultItem) |
---|
| 40 | url = None |
---|
| 41 | title = None |
---|
| 42 | description = None |
---|
[6116] | 43 | |
---|
[6207] | 44 | def __init__(self, context, view): |
---|
| 45 | self.context = context |
---|
| 46 | self.url = view.url(context) |
---|
| 47 | self.title = context.title |
---|
| 48 | self.description = '' |
---|
Note: See
TracBrowser for help on using the repository browser.