[CMF-checkins] CVS: CMF/CMFCollector/skins/collector - collector_search.py:1.1

Ken Manheimer klm@zope.com
Tue, 16 Oct 2001 15:08:43 -0400


Update of /cvs-repository/CMF/CMFCollector/skins/collector
In directory cvs.zope.org:/tmp/cvs-serv9018/skins/collector

Added Files:
	collector_search.py 
Log Message:
Process search-form parameters to yield the search hits.

This is (a reworked version of) what andrew checked in as
"search_collector.py".  The name would have collided with
collector_search.pt, but that's unnecessary since the search is now
consolidated with the browse page.


=== Added File CMF/CMFCollector/skins/collector/collector_search.py ===
## Script (Python) "search_collector.py"
##title=Build Collector Search

query = {}
query['Type'] = "Collector Issue"
query['path'] = context.absolute_url(1)

reqget = context.REQUEST.get
subj_items = []

def supplement_query(field, reqget=reqget, query=query):
    val = reqget(field, None)
    if val:
        query[field] = val
def supplement_subject_one(field, reqget=reqget, items=subj_items):
    val = reqget(field, None)
    if val:
        items.append('%s:%s' % (field, val))
def supplement_subject_many(field, reqget=reqget, items=subj_items):
    vals = reqget(field, [])
    for i in vals:
        items.append('%s:%s' % (field, i))

supplement_query("SearchableText")
supplement_query("Creator")
supplement_subject_many("classifications")
supplement_subject_many("severities")
supplement_subject_one("resolution")
supplement_subject_one("security_related")
supplement_subject_one("reported_version")
supplement_subject_one("security_related")
supplement_subject_one("reported_version")
if query:
    query["Subject"] = subj_items

return context.portal_catalog(REQUEST=query)