source: products/qTopic/branches/plone2.1/skins/qtopic/validate_add_criterion.vpy @ 1

Last change on this file since 1 was 1, checked in by myroslav, 19 years ago

Building directory structure

File size: 864 bytes
Line 
1## Script (Python) "validate_add_criterion"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##
9request = context.REQUEST
10indexId=request.get('field')
11criterion_type=request.get('criterion_type')
12supported = context.validateAddCriterion(indexId, criterion_type)
13
14atct_tool = context.portal_atct
15
16catalog = 'portal_catalog'
17if hasattr(context, 'getCatalog'):
18   catalog = context.getCatalog()
19
20index_obj = atct_tool.getIndex(indexId, catalog)
21
22allowed_criteria = index_obj.criteria
23
24if not supported or criterion_type not in allowed_criteria:
25    msg = 'Criterion of type ' +\
26          '"%s" not added, it does not work with index "%s".' % (criterion_type, indexId)
27    return state.set(status='failure', portal_status_message=msg )
28else:
29    return state.set(status='success')
Note: See TracBrowser for help on using the repository browser.