1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 =====================
19 HTML forms reloaded
20 =====================
21
22 Form helper classes.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26 __all__ = [
27 'ParameterAdapterInterface', 'PreProcInterface', 'PostProcInterface',
28 ]
29
30
32 """
33 Interface for a request parameter adapter suitable for `HTMLForm`
34 """
35
37 """
38 Determine all parameters submitted under a name
39
40 :Parameters:
41 `name` : ``str``
42 The name to look up
43
44 :Return: The List of values (maybe empty) (``[u'value', ...]``)
45 :Rtype: ``list``
46 """
47
49 """
50 Determine one parameter of all submitted under a name
51
52 It doesn't have to be the first parameter, but it should work
53 deterministically, i.e. the method should always return the same
54 value for the same name.
55
56 :Parameters:
57 `name` : ``str``
58 The name to look up
59
60 `default` : ``basestring``
61 The returned value if name could not be found
62
63 :Return: The found value. If it was not found, `default` is returned
64 :Rtype: ``basestring``
65 """
66
67
69 """ Interface for node processors """
70
71 - def __call__(self, method, node, kwargs):
72 """
73 Pre process the node
74
75 :Parameters:
76 `method` : ``str``
77 The name of the method (like ``'text'`` or ``'checkbox'``)
78
79 `node` : `tdi.nodetree.Node`
80 The node to process
81
82 `kwargs` : ``dict``
83 The arguments of the HTMLForm method
84
85 :Return: node and kwargs again (they do not need to be the same as
86 input). Keys appearing in kwargs override the original
87 parameters then. (``(node, kwargs)``)
88 :Rtype: ``tuple``
89 """
90
91
92 -class PostProcInterface(object):
93 """ Interface for node processors """
94
95 - def __call__(self, method, node, kwargs):
96 """
97 Post process the node
98
99 :Parameters:
100 `method` : ``str``
101 The name of the method (like ``'text'`` or ``'checkbox'``)
102
103 `node` : `tdi.nodetree.Node`
104 The node to process
105
106 `kwargs` : ``dict``
107 The arguments of the HTMLForm method
108 """
109