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.179564
37 __CHEETAH_genTimestamp__ = 'Thu Sep 27 12:06:48 2007'
38 __CHEETAH_src__ = 'MeasuresDataTmpl.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 <table class="measures">
87 <thead>
88 <tr>
89 <td>Date</td>
90 ''')
91 for f in VFFSL(SL,"data.fields",True):
92 write(' <td>')
93 _v = VFFSL(SL,"f",True)
94 if _v is not None: write(_filter(_v, rawExpr='$f'))
95 write('</td>\n')
96 write(''' </tr>
97 </thead>
98 <tbody>
99 ''')
100 for i in range(len(VFFSL(SL,"data.measures",True))):
101 if VFFSL(SL,"i",True) % 2 == 0:
102 row_class = "even"
103 else:
104 row_class = "odd"
105 m = VFN(VFFSL(SL,"data",True),"measures",True)[VFFSL(SL,"i",True)]
106 write(' <tr class="')
107 _v = VFFSL(SL,"row_class",True)
108 if _v is not None: write(_filter(_v, rawExpr='$row_class'))
109 write('">\n <td>')
110 _v = VFN(VFFSL(SL,"m",True),"get_date",False)()
111 if _v is not None: write(_filter(_v, rawExpr='$m.get_date()'))
112 write('</td>\n')
113 for f in VFFSL(SL,"data.fields",True):
114 write(' <td>')
115 _v = VFN(VFFSL(SL,"m",True),"get_value",False)(VFFSL(SL,"f",True))
116 if _v is not None: write(_filter(_v, rawExpr='$m.get_value($f)'))
117 write('</td>\n')
118 write(' </tr>\n')
119 write(''' </tbody>
120 <tfoot>
121 <tr>
122 ''')
123 nf = VFFSL(SL,"len",False)(VFFSL(SL,"data.fields",True))+1
124 nm = VFFSL(SL,"len",False)(VFFSL(SL,"data.measures",True))
125 write(' <td colspan="')
126 _v = VFFSL(SL,"nf",True)
127 if _v is not None: write(_filter(_v, rawExpr='$nf'))
128 write('" align="right">')
129 _v = VFFSL(SL,"nm",True)
130 if _v is not None: write(_filter(_v, rawExpr='$nm'))
131 write(''' measures</td>
132 </tr>
133 </tfoot>
134 </table>
135 ''')
136
137
138
139
140 return _dummyTrans and trans.response().getvalue() or ""
141
142
143
144
145
146 _CHEETAH__instanceInitialized = False
147
148 _CHEETAH_version = __CHEETAH_version__
149
150 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
151
152 _CHEETAH_genTime = __CHEETAH_genTime__
153
154 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
155
156 _CHEETAH_src = __CHEETAH_src__
157
158 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
159
160 _mainCheetahMethod_for_MeasuresDataTmpl= 'respond'
161
162
163
164 if not hasattr(MeasuresDataTmpl, '_initCheetahAttributes'):
165 templateAPIClass = getattr(MeasuresDataTmpl, '_CHEETAH_templateClass', Template)
166 templateAPIClass._addCheetahPlumbingCodeToClass(MeasuresDataTmpl)
167
168
169
170
171
172
173
174
175 if __name__ == '__main__':
176 from Cheetah.TemplateCmdLineIface import CmdLineIface
177 CmdLineIface(templateObj=MeasuresDataTmpl()).run()
178