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

Source Code for Module tdi.tools.htmlform._processors

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