source: WAeUP_SRP/trunk/skins/waeup_default/waeup_search.py @ 17718

Last change on this file since 17718 was 2308, checked in by Henrik Bettermann, 17 years ago

simplify search to improve speed

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