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

Source Code for Module tdi.tools.htmlform._interfaces

  1  # -*- coding: ascii -*- 
  2  # 
  3  # Copyright 2007 - 2012 
  4  # Andr\xe9 Malo or his licensors, as applicable 
  5  # 
  6  # Licensed under the Apache License, Version 2.0 (the "License"); 
  7  # you may not use this file except in compliance with the License. 
  8  # You may obtain a copy of the License at 
  9  # 
 10  #     http://www.apache.org/licenses/LICENSE-2.0 
 11  # 
 12  # Unless required by applicable law or agreed to in writing, software 
 13  # distributed under the License is distributed on an "AS IS" BASIS, 
 14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 15  # See the License for the specific language governing permissions and 
 16  # limitations under the License. 
 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   
31 -class ParameterAdapterInterface(object):
32 """ 33 Interface for a request parameter adapter suitable for `HTMLForm` 34 """ 35
36 - def getlist(self, name):
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
48 - def getfirst(self, name, default=None):
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
68 -class PreProcInterface(object):
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