source: products/qPloneCaptchas/tags/1.3.0/skins/plone_captchas/prefs_captchas_setup.cpy

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

Building directory structure

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1## Controller Script (Python) "prefs_captchas_setup"
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=Set necessary skin
10##
11from Products.CMFCore.utils import getToolByName
12import string
13
14def exchangeLayers(layer1, layer2):
15    for skin in skinstool.getSkinSelections():
16        path = skinstool.getSkinPath(skin)
17        path = map( string.strip, string.split( path,',' ))
18        try:
19            i = path.index(layer1)
20            path.remove(layer1)
21            path.insert(i, layer2)
22        except ValueError:
23            pass
24        path = string.join( path, ', ' )
25        skinstool.addSkinSelection( skin, path )
26
27form = context.REQUEST.form
28request_ids = form.keys()
29ct = form.get('static_captchas')
30skinstool = getToolByName(context, 'portal_skins')
31if ct == 'static':
32    exchangeLayers('plone_captchas/dynamic', 'plone_captchas/static')
33else:
34    exchangeLayers('plone_captchas/static', 'plone_captchas/dynamic')
35
36captcha_props = getToolByName(context, 'portal_properties')['qPloneCaptchas']
37
38property_map=[(m['id'], m['type']) for m in captcha_props.propertyMap() if not m['id']=='title']
39kw={}
40for id,type in property_map:
41    if type == 'boolean':
42        print id
43        if id in request_ids:
44            kw[id] = True
45        else:
46            kw[id] = False
47    else:
48        if id in request_ids:
49            kw[id] = form[id]
50
51captcha_props.manage_changeProperties(kw)
52
53return state.set(portal_status_message = 'Changes saved.')
Note: See TracBrowser for help on using the repository browser.