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.0rc7'
35 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 7)
36 __CHEETAH_genTime__ = 1190887608.3729761
37 __CHEETAH_genTimestamp__ = 'Thu Sep 27 12:06:48 2007'
38 __CHEETAH_src__ = 'TableDataTmpl.tmpl'
39 __CHEETAH_srcLastModified__ = 'Tue Jan 23 10:43:33 2007'
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>\n')
99 write(''' </tr>
100 </thead>
101 <tbody>
102 ''')
103 if VFFSL(SL,"data.table_data",True) == None:
104 write(' <tr class="even">\n')
105 cols = VFFSL(SL,"len",False)(VFFSL(SL,"data.columns_format",True))
106 write(' <td colspan=')
107 _v = VFFSL(SL,"cols",True)
108 if _v is not None: write(_filter(_v, rawExpr='$cols'))
109 write(' ')
110 _v = VFFSL(SL,"attrs",True)
111 if _v is not None: write(_filter(_v, rawExpr='$attrs'))
112 write('>Donn\xc3\xa9es non disponibles</td>\n </tr>\n')
113 else:
114 for i in range(len(VFFSL(SL,"data.table_data",True))):
115 if (VFFSL(SL,"i",True)+1) % 2 == 0:
116 row_class = "even"
117 else:
118 row_class = "odd"
119 row = VFN(VFFSL(SL,"data",True),"table_data",True)[VFFSL(SL,"i",True)]
120 write(' <tr class="')
121 _v = VFFSL(SL,"row_class",True)
122 if _v is not None: write(_filter(_v, rawExpr='$row_class'))
123 write('">\n')
124 for (field, title, attrs, format) in VFFSL(SL,"data.columns_format",True):
125 write(' <td ')
126 _v = VFFSL(SL,"attrs",True)
127 if _v is not None: write(_filter(_v, rawExpr='$attrs'))
128 write('>')
129 _v = VFFSL(SL,"format",False)(VFFSL(SL,"row",True)[VFFSL(SL,"field",True)])
130 if _v is not None: write(_filter(_v, rawExpr='$format($row[$field])'))
131 write('</td>\n')
132 write(' </tr>\n')
133 write(' </tbody>\n</table>\n')
134
135
136
137
138 return _dummyTrans and trans.response().getvalue() or ""
139
140
141
142
143
144 _CHEETAH__instanceInitialized = False
145
146 _CHEETAH_version = __CHEETAH_version__
147
148 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
149
150 _CHEETAH_genTime = __CHEETAH_genTime__
151
152 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
153
154 _CHEETAH_src = __CHEETAH_src__
155
156 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
157
158 _mainCheetahMethod_for_TableDataTmpl= 'respond'
159
160
161
162 if not hasattr(TableDataTmpl, '_initCheetahAttributes'):
163 templateAPIClass = getattr(TableDataTmpl, '_CHEETAH_templateClass', Template)
164 templateAPIClass._addCheetahPlumbingCodeToClass(TableDataTmpl)
165
166
167
168
169
170
171
172
173 if __name__ == '__main__':
174 from Cheetah.TemplateCmdLineIface import CmdLineIface
175 CmdLineIface(templateObj=TableDataTmpl()).run()
176