Package tdi :: Package tools :: Package htmlform :: Module _interfaces
[frames] | no frames]

Source Code for Module tdi.tools.htmlform._interfaces

  1  # -*- coding: ascii -*- 
  2  u""" 
  3  :Copyright: 
  4   
  5   Copyright 2007 - 2013 
  6   Andr\xe9 Malo or his licensors, as applicable 
  7   
  8  :License: 
  9   
 10   Licensed under the Apache License, Version 2.0 (the "License"); 
 11   you may not use this file except in compliance with the License. 
 12   You may obtain a copy of the License at 
 13   
 14       http://www.apache.org/licenses/LICENSE-2.0 
 15   
 16   Unless required by applicable law or agreed to in writing, software 
 17   distributed under the License is distributed on an "AS IS" BASIS, 
 18   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 19   See the License for the specific language governing permissions and 
 20   limitations under the License. 
 21   
 22  ===================== 
 23   HTML forms reloaded 
 24  ===================== 
 25   
 26  Form helper classes. 
 27  """ 
 28  __author__ = u"Andr\xe9 Malo" 
 29  __docformat__ = "restructuredtext en" 
 30  __all__ = [ 
 31      'ParameterAdapterInterface', 'PreProcInterface', 'PostProcInterface', 
 32  ] 
 33   
 34   
35 -class ParameterAdapterInterface(object):
36 """ 37 Interface for a request parameter adapter suitable for `HTMLForm` 38 """ 39
40 - def getlist(self, name):
41 """ 42 Determine all parameters submitted under a name 43 44 :Parameters: 45 `name` : ``str`` 46 The name to look up 47 48 :Return: The List of values (maybe empty) (``[u'value', ...]``) 49 :Rtype: ``list`` 50 """
51
52 - def getfirst(self, name, default=None):
53 """ 54 Determine one parameter of all submitted under a name 55 56 It doesn't have to be the first parameter, but it should work 57 deterministically, i.e. the method should always return the same 58 value for the same name. 59 60 :Parameters: 61 `name` : ``str`` 62 The name to look up 63 64 `default` : ``basestring`` 65 The returned value if name could not be found 66 67 :Return: The found value. If it was not found, `default` is returned 68 :Rtype: ``basestring`` 69 """
70 71
72 -class PreProcInterface(object):
73 """ Interface for node processors """ 74
75 - def __call__(self, method, node, kwargs):
76 """ 77 Pre process the node 78 79 :Parameters: 80 `method` : ``str`` 81 The name of the method (like ``'text'`` or ``'checkbox'``) 82 83 `node` : `tdi.nodetree.Node` 84 The node to process 85 86 `kwargs` : ``dict`` 87 The arguments of the HTMLForm method 88 89 :Return: node and kwargs again (they do not need to be the same as 90 input). Keys appearing in kwargs override the original 91 parameters then. (``(node, kwargs)``) 92 :Rtype: ``tuple`` 93 """
94 95
96 -class PostProcInterface(object):
97 """ Interface for node processors """ 98
99 - def __call__(self, method, node, kwargs):
100 """ 101 Post process the node 102 103 :Parameters: 104 `method` : ``str`` 105 The name of the method (like ``'text'`` or ``'checkbox'``) 106 107 `node` : `tdi.nodetree.Node` 108 The node to process 109 110 `kwargs` : ``dict`` 111 The arguments of the HTMLForm method 112 """
113