Un peu de ménage, opacité progressive, lors de l'upload.
[Plinn.git] / skins / control / doFormSearch.py
1 ## Script (Python) "doFormSearch"
2 ##parameters=REQUEST
3 ##title=Pre-process form variables, then return catalog query results.
4 ##
5 vars = REQUEST.form
6 form_vars = {}
7 skip_vars = ['strCreator']
8 select_vars = ( 'review_state'
9 , 'Subject'
10 , 'portal_type'
11 )
12 date_vars = ('created',
13 )
14 epoch = DateTime("1970/01/01 00:00:00 GMT")
15
16 for k, v in vars.items():
17
18 if k in select_vars:
19 if same_type( v, [] ):
20 v = filter( None, v )
21 if not v:
22 continue
23
24 if k in date_vars:
25 if v == epoch and vars.get(k+'_usage') == 'range:min':
26 skip_vars.append(k+'_usage')
27 continue
28
29 form_vars[ k ] = v
30
31 if form_vars.has_key('portal_type') :
32 try : form_vars['portal_type'].remove('Member Data')
33 except ValueError : pass
34 else :
35 form_vars['portal_type'] = context.portal_types.objectIds()
36
37 for k in skip_vars:
38 if form_vars.has_key(k) :
39 del form_vars[k]
40
41 if vars.has_key('strCreator') :
42 form_vars['listCreators'] = [ m.getId() for m in context.portal_membership.looseSearchMembers(vars['strCreator']) ]
43
44 return context.portal_catalog( form_vars )