source: products/qPloneSkinDump/branches/multipleslots/skins/qploneskindump/validate_qploneskindump_form.vpy @ 1552

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

Building directory structure

File size: 1.5 KB
Line 
1## Controller Python Script "validate_qploneskindump_form.vpy"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters=
9##title=Validates qPloneSkinDump form
10##
11
12from Products.CMFCore.utils import getToolByName
13from Products.qPloneSkinDump.qPloneSkinDump import isValidProductName, isValidDirName
14errors = state.getErrors()
15
16def update_errors(existent_errors, new_errors):
17    for e_name, e_value in new_errors.items():
18        if e_name in existent_errors.keys():
19            existent_errors[e_name] = existent_errors[e_name] + e_value
20        else:
21            existent_errors[e_name] = e_value
22
23# Check REQUIRED fields
24REQUIRED_FIELDS = ['ZMISkinName', 'ZMIBaseSkinName', 'FSProductName', 'FSSkinDirectory']
25theform = {}
26for f in REQUIRED_FIELDS:
27    fdata = context.REQUEST.get(f, None)
28    if not fdata:
29        update_errors(errors, {f:u'Field is required.'})
30    theform[f]=fdata
31
32if not( theform['FSProductName'] and isValidProductName(theform['FSProductName']) ):
33    update_errors(errors, {'FSProductName': u"Not valid Product name - read help attentively."})
34
35if not( theform['FSSkinDirectory'] and isValidDirName(theform['FSSkinDirectory']) ):
36    update_errors(errors, {'FSSkinDirectory': u"Not valid Skin name - read help attentively."})
37
38if errors:
39    return state.set(status='failure', errors=errors, portal_status_message='Please correct the indicated errors.')
40
41return state
Note: See TracBrowser for help on using the repository browser.