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__ = 1190887606.5106139
37 __CHEETAH_genTimestamp__ = 'Thu Sep 27 12:06:46 2007'
38 __CHEETAH_src__ = 'PageTmpl.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
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>\n <link rel="stylesheet" href="')
95 _v = VFFSL(SL,"static_base",True)
96 if _v is not None: write(_filter(_v, rawExpr='$static_base'))
97 write('''/stylesheet.css" type="text/css" />
98 </head>
99
100 <body>
101 ''')
102
103
104
105
106 return _dummyTrans and trans.response().getvalue() or ""
107
108
110
111
112
113
114 trans = KWS.get("trans")
115 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
116 trans = self.transaction
117 if not trans:
118 trans = DummyTransaction()
119 _dummyTrans = True
120 else: _dummyTrans = False
121 write = trans.response().write
122 SL = self._CHEETAH__searchList
123 _filter = self._CHEETAH__currentFilter
124
125
126
127
128 write(' </body>\n</html>\n')
129
130
131
132
133 return _dummyTrans and trans.response().getvalue() or ""
134
135
136 - def respond(self, trans=None):
137
138
139
140
141 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
142 trans = self.transaction
143 if not trans:
144 trans = DummyTransaction()
145 _dummyTrans = True
146 else: _dummyTrans = False
147 write = trans.response().write
148 SL = self._CHEETAH__searchList
149 _filter = self._CHEETAH__currentFilter
150
151
152
153
154 write('<!-- #encoding utf-8 -->\n\n')
155
156
157
158
159 return _dummyTrans and trans.response().getvalue() or ""
160
161
162
163
164
165 _CHEETAH__instanceInitialized = False
166
167 _CHEETAH_version = __CHEETAH_version__
168
169 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
170
171 _CHEETAH_genTime = __CHEETAH_genTime__
172
173 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
174
175 _CHEETAH_src = __CHEETAH_src__
176
177 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
178
179 _mainCheetahMethod_for_PageTmpl= 'respond'
180
181
182
183 if not hasattr(PageTmpl, '_initCheetahAttributes'):
184 templateAPIClass = getattr(PageTmpl, '_CHEETAH_templateClass', Template)
185 templateAPIClass._addCheetahPlumbingCodeToClass(PageTmpl)
186
187
188
189
190
191
192
193
194 if __name__ == '__main__':
195 from Cheetah.TemplateCmdLineIface import CmdLineIface
196 CmdLineIface(templateObj=PageTmpl()).run()
197