Last change
on this file since 3294 was
2308,
checked in by Henrik Bettermann, 17 years ago
|
simplify search to improve speed
|
File size:
718 bytes
|
Rev | Line | |
---|
[2308] | 1 | ##parameters=query={}, REQUEST=None |
---|
| 2 | # $Id: search.py 49965 2006-11-10 00:22:57Z madarche $ |
---|
| 3 | """ |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | from zLOG import LOG, DEBUG, INFO |
---|
| 7 | from Products.ZCTextIndex.ParseTree import ParseError |
---|
| 8 | ParseErrors = (ParseError,) |
---|
| 9 | try: |
---|
| 10 | from Products.TextIndexNG2.BaseParser import QueryParserError |
---|
| 11 | ParseErrors += (QueryParserError,) |
---|
| 12 | except ImportError: |
---|
| 13 | pass |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | catalog = context.portal_catalog |
---|
| 17 | |
---|
| 18 | if REQUEST is not None: |
---|
| 19 | query.update(REQUEST.form) |
---|
| 20 | |
---|
| 21 | for k, v in query.items(): |
---|
| 22 | if not v or same_type(v, []) and not filter(None, v): |
---|
| 23 | del query[k] |
---|
| 24 | |
---|
| 25 | try: |
---|
| 26 | brains = catalog(**query) |
---|
| 27 | except ParseErrors: |
---|
| 28 | LOG('CPSDefault.search', INFO, 'got an exception during search %s' % query) |
---|
| 29 | return [] |
---|
| 30 | |
---|
| 31 | return brains |
---|
Note: See
TracBrowser for help on using the repository browser.