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__ = 1278598944.699945
37 __CHEETAH_genTimestamp__ = 'Thu Jul 8 16:22:24 2010'
38 __CHEETAH_src__ = 'PageTmpl.tmpl'
39 __CHEETAH_srcLastModified__ = 'Thu Jul 8 16:22:19 2010'
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
51 -class PageTmpl(Template):
52
53
54
55
56
57 - def __init__(self, *args, **KWs):
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
68 - def head(self, pagetitle, **KWS):
69
70
71
72
73 trans = KWS.get("trans")
74 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
75 trans = self.transaction
76 if not trans:
77 trans = DummyTransaction()
78 _dummyTrans = True
79 else: _dummyTrans = False
80 write = trans.response().write
81 SL = self._CHEETAH__searchList
82 _filter = self._CHEETAH__currentFilter
83
84
85
86
87 write('''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
88 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
89 <head>
90 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
91 <title>''')
92 _v = VFFSL(SL,"pagetitle",True)
93 if _v is not None: write(_filter(_v, rawExpr='$pagetitle'))
94 write('''</title>
95 <link rel="stylesheet" href="''')
96 _v = VFFSL(SL,"static_base",True)
97 if _v is not None: write(_filter(_v, rawExpr='$static_base'))
98 write('''/stylesheet.css" type="text/css" />
99 </head>
100
101 <body>
102 ''')
103
104
105
106
107 return _dummyTrans and trans.response().getvalue() or ""
108
109
111
112
113
114
115 trans = KWS.get("trans")
116 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
117 trans = self.transaction
118 if not trans:
119 trans = DummyTransaction()
120 _dummyTrans = True
121 else: _dummyTrans = False
122 write = trans.response().write
123 SL = self._CHEETAH__searchList
124 _filter = self._CHEETAH__currentFilter
125
126
127
128
129 write(''' </body>
130 </html>
131 ''')
132
133
134
135
136 return _dummyTrans and trans.response().getvalue() or ""
137
138
139 - def respond(self, trans=None):
140
141
142
143
144 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
145 trans = self.transaction
146 if not trans:
147 trans = DummyTransaction()
148 _dummyTrans = True
149 else: _dummyTrans = False
150 write = trans.response().write
151 SL = self._CHEETAH__searchList
152 _filter = self._CHEETAH__currentFilter
153
154
155
156
157 write('''<!-- #encoding utf-8 -->
158
159 ''')
160
161
162
163
164 return _dummyTrans and trans.response().getvalue() or ""
165
166
167
168
169
170 _CHEETAH__instanceInitialized = False
171
172 _CHEETAH_version = __CHEETAH_version__
173
174 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
175
176 _CHEETAH_genTime = __CHEETAH_genTime__
177
178 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
179
180 _CHEETAH_src = __CHEETAH_src__
181
182 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
183
184 _mainCheetahMethod_for_PageTmpl= 'respond'
185
186
187
188 if not hasattr(PageTmpl, '_initCheetahAttributes'):
189 templateAPIClass = getattr(PageTmpl, '_CHEETAH_templateClass', Template)
190 templateAPIClass._addCheetahPlumbingCodeToClass(PageTmpl)
191
192
193
194
195
196
197
198
199 if __name__ == '__main__':
200 from Cheetah.TemplateCmdLineIface import CmdLineIface
201 CmdLineIface(templateObj=PageTmpl()).run()
202