1
2
3
4
5
6
7
8 import sys
9 import os
10 import os.path
11 from os.path import getmtime, exists
12 import time
13 import types
14 import __builtin__
15 from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
16 from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
17 from Cheetah.Template import Template
18 from Cheetah.DummyTransaction import DummyTransaction
19 from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
20 from Cheetah.CacheRegion import CacheRegion
21 import Cheetah.Filters as Filters
22 import Cheetah.ErrorCatchers as ErrorCatchers
23
24
25
26 try:
27 True, False
28 except NameError:
29 True, False = (1==1), (1==0)
30 VFFSL=valueFromFrameOrSearchList
31 VFSL=valueFromSearchList
32 VFN=valueForName
33 currentTime=time.time
34 __CHEETAH_version__ = '2.0.1'
35 __CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
36 __CHEETAH_genTime__ = 1389100489.636806
37 __CHEETAH_genTimestamp__ = 'Tue Jan 7 14:14:49 2014'
38 __CHEETAH_src__ = 'TableDataTmpl.tmpl'
39 __CHEETAH_srcLastModified__ = 'Tue Jan 7 14:06:55 2014'
40 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
41
42 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
43 raise AssertionError(
44 'This template was compiled with Cheetah version'
45 ' %s. Templates compiled before version %s must be recompiled.'%(
46 __CHEETAH_version__, RequiredCheetahVersion))
47
48
49
50
52
53
54
55
56
58
59 Template.__init__(self, *args, **KWs)
60 if not self._CHEETAH__instanceInitialized:
61 cheetahKWArgs = {}
62 allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
63 for k,v in KWs.items():
64 if k in allowedKWs: cheetahKWArgs[k] = v
65 self._initCheetahInstance(**cheetahKWArgs)
66
67
69
70
71
72
73 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
74 trans = self.transaction
75 if not trans:
76 trans = DummyTransaction()
77 _dummyTrans = True
78 else: _dummyTrans = False
79 write = trans.response().write
80 SL = self._CHEETAH__searchList
81 _filter = self._CHEETAH__currentFilter
82
83
84
85
86 write('''<!-- MeasuresDataTmpl #encoding utf-8 -->
87 <table class="table">
88 <thead>
89 <tr>
90 ''')
91 for field, title, attrs, format in VFFSL(SL,"data.columns_format",True):
92 write(''' <td ''')
93 _v = VFFSL(SL,"attrs",True)
94 if _v is not None: write(_filter(_v, rawExpr='$attrs'))
95 write('''>''')
96 _v = VFFSL(SL,"title",True)
97 if _v is not None: write(_filter(_v, rawExpr='$title'))
98 write('''</td>
99 ''')
100 write(''' </tr>
101 </thead>
102 <tbody>
103 ''')
104 if VFFSL(SL,"data.table_data",True) == None:
105 write(''' <tr class="even">
106 ''')
107 cols = VFFSL(SL,"len",False)(VFFSL(SL,"data.columns_format",True))
108 write(''' <td colspan=''')
109 _v = VFFSL(SL,"cols",True)
110 if _v is not None: write(_filter(_v, rawExpr='$cols'))
111 write(''' ''')
112 _v = VFFSL(SL,"attrs",True)
113 if _v is not None: write(_filter(_v, rawExpr='$attrs'))
114 write('''>Donn\xc3\xa9es non disponibles</td>
115 </tr>
116 ''')
117 else:
118 for i in range(len(VFFSL(SL,"data.table_data",True))):
119 if (VFFSL(SL,"i",True)+1) % 2 == 0:
120 row_class = "even"
121 else:
122 row_class = "odd"
123 row = VFN(VFFSL(SL,"data",True),"table_data",True)[VFFSL(SL,"i",True)]
124 write(''' <tr class="''')
125 _v = VFFSL(SL,"row_class",True)
126 if _v is not None: write(_filter(_v, rawExpr='$row_class'))
127 write('''">
128 ''')
129 for (field, title, attrs, format) in VFFSL(SL,"data.columns_format",True):
130 write(''' <td ''')
131 _v = VFFSL(SL,"attrs",True)
132 if _v is not None: write(_filter(_v, rawExpr='$attrs'))
133 write('''>''')
134 _v = VFFSL(SL,"format",False)(VFFSL(SL,"row",True)[VFFSL(SL,"field",True)])
135 if _v is not None: write(_filter(_v, rawExpr='$format($row[$field])'))
136 write('''</td>
137 ''')
138 write(''' </tr>
139 ''')
140 write(''' </tbody>
141 </table>
142 ''')
143
144
145
146
147 return _dummyTrans and trans.response().getvalue() or ""
148
149
150
151
152
153 _CHEETAH__instanceInitialized = False
154
155 _CHEETAH_version = __CHEETAH_version__
156
157 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
158
159 _CHEETAH_genTime = __CHEETAH_genTime__
160
161 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
162
163 _CHEETAH_src = __CHEETAH_src__
164
165 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
166
167 _mainCheetahMethod_for_TableDataTmpl= 'respond'
168
169
170
171 if not hasattr(TableDataTmpl, '_initCheetahAttributes'):
172 templateAPIClass = getattr(TableDataTmpl, '_CHEETAH_templateClass', Template)
173 templateAPIClass._addCheetahPlumbingCodeToClass(TableDataTmpl)
174
175
176
177
178
179
180
181
182 if __name__ == '__main__':
183 from Cheetah.TemplateCmdLineIface import CmdLineIface
184 CmdLineIface(templateObj=TableDataTmpl()).run()
185