Annotation of kupuMPIWG/plone/kupu_plone_layer/kupuSearch.py, revision 1.1
1.1 ! dwinter 1: ## Script (Python) "kupuSearch"
! 2: ##title=Search the portal catalog
! 3: ##bind container=container
! 4: ##bind context=context
! 5: ##bind namespace=
! 6: ##bind script=script
! 7: ##bind subpath=traverse_subpath
! 8: ##parameters=
! 9: from Products.CMFCore.utils import getToolByName
! 10:
! 11: request = context.REQUEST
! 12: response = request.RESPONSE
! 13: response.setHeader('Cache-Control', 'no-cache')
! 14:
! 15: catalog = getToolByName(context, 'portal_catalog')
! 16: kupu_tool = getToolByName(context, 'kupu_library_tool')
! 17:
! 18: request = context.REQUEST
! 19: # the default resource type is mediaobject
! 20: resource_type = request.get('resource_type', 'mediaobject')
! 21: portal_types = kupu_tool.queryPortalTypesForResourceType(resource_type, ())
! 22:
! 23: search_params = {}
! 24: search_params.update(request.form)
! 25: search_params['portal_type'] = portal_types
! 26: search_params['review_state'] = 'visible', 'published'
! 27:
! 28: # Get the maximum number of results with 500 being the default and
! 29: # absolute maximum.
! 30: abs_max = 500
! 31: max = request.get('max_results', abs_max)
! 32: if max > abs_max:
! 33: max = abs_max
! 34:
! 35: results = context.queryCatalog(search_params)[:max]
! 36: return context.kupuInfoForBrains(results)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>