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

Ken Manheimer klm@zope.com
Tue, 16 Oct 2001 18:38:57 -0400


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

Modified Files:
	collector_search.py 
Log Message:
Provide for different index and (search) field names, and implement a
few more fields.

Still have to unravel the operations for the consolidated Subject
attributes.


=== CMF/CMFCollector/skins/collector/collector_search.py 1.1 => 1.2 ===
 
 query = {}
+query['sort_on'] = 'id'
 query['Type'] = "Collector Issue"
 query['path'] = context.absolute_url(1)
 
 reqget = context.REQUEST.get
 subj_items = []
 
-def supplement_query(field, reqget=reqget, query=query):
+def supplement_query(field, index_name=None, reqget=reqget, query=query):
+    if not index_name: index_name = field
     val = reqget(field, None)
     if val:
-        query[field] = val
-def supplement_subject_one(field, reqget=reqget, items=subj_items):
+        query[index_name] = val
+def supplement_subject_one(field, index_name=None, reqget=reqget, items=subj_items):
+    if not index_name: index_name = field
     val = reqget(field, None)
     if val:
-        items.append('%s:%s' % (field, val))
-def supplement_subject_many(field, reqget=reqget, items=subj_items):
+        items.append('%s:%s' % (index_name, val))
+def supplement_subject_many(field, index_name=None, reqget=reqget, items=subj_items):
+    if not index_name: index_name = field
     vals = reqget(field, [])
     for i in vals:
-        items.append('%s:%s' % (field, i))
+        items.append('%s:%s' % (index_name, i))
 
 supplement_query("SearchableText")
 supplement_query("Creator")
-supplement_subject_many("classifications")
-supplement_subject_many("severities")
+supplement_query("status", "review_state")
+supplement_subject_many("classifications", "classification")
+supplement_subject_many("severities", "severity")
+supplement_subject_many("supporters", "assigned_to")
 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:
+if subj_items:
     query["Subject"] = subj_items
 
 return context.portal_catalog(REQUEST=query)
+
+# Use "sort_on='index_name'" to sort - default, id