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

Source Code for Module tdi.tools.htmlform._processors

 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 form processors 
20  ====================== 
21   
22  HTML form processors. 
23  """ 
24  __author__ = u"Andr\xe9 Malo" 
25  __docformat__ = "restructuredtext en" 
26  __all__ = ['TabIndexer'] 
27   
28  import itertools as _it 
29   
30  from tdi.tools.htmlform._interfaces import PostProcInterface 
31   
32   
33 -class TabIndexer(object):
34 """ 35 Automatic tabindex filler to be used as `HTMLForm` post processor 36 37 :IVariables: 38 `next_index` : ``callable`` 39 Function to deliver the next index 40 """ 41 __implements__ = [PostProcInterface] 42
43 - def __init__(self, start=1):
44 """ 45 Initialization 46 47 :Parameters: 48 `start` : ``int`` 49 Tabindex to start with 50 """ 51 self.next_index = _it.count(start).next
52
53 - def __call__(self, method, node, kwargs):
54 """ 55 Add tabindex to form elements 56 57 Exceptions: ``<form>``, ``<option>``, ``<datalist>``, 58 ``<input type="hidden">`` 59 60 :See: `PostProcInterface` 61 """ 62 if method not in ('form', 'option', 'hidden', 'datalist'): 63 node['tabindex'] = self.next_index()
64