| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""A Skeleton HTML page template, that provides basic structure and utility methods. |
| 5 |
""" |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
import sys |
| 11 |
import os |
| 12 |
import os.path |
| 13 |
try: |
| 14 |
import builtins as builtin |
| 15 |
except ImportError: |
| 16 |
import __builtin__ as builtin |
| 17 |
from os.path import getmtime, exists |
| 18 |
import time |
| 19 |
import types |
| 20 |
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion |
| 21 |
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple |
| 22 |
from Cheetah.Template import Template |
| 23 |
from Cheetah.DummyTransaction import * |
| 24 |
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList |
| 25 |
from Cheetah.CacheRegion import CacheRegion |
| 26 |
import Cheetah.Filters as Filters |
| 27 |
import Cheetah.ErrorCatchers as ErrorCatchers |
| 28 |
from Cheetah.compat import unicode |
| 29 |
from Cheetah.Templates._SkeletonPage import _SkeletonPage |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
VFFSL=valueFromFrameOrSearchList |
| 34 |
VFSL=valueFromSearchList |
| 35 |
VFN=valueForName |
| 36 |
currentTime=time.time |
| 37 |
__CHEETAH_version__ = '3.0.0' |
| 38 |
__CHEETAH_versionTuple__ = (3, 0, 0, 'development', 1) |
| 39 |
__CHEETAH_genTime__ = 1490043964.453685 |
| 40 |
__CHEETAH_genTimestamp__ = 'Tue Mar 21 00:06:04 2017' |
| 41 |
__CHEETAH_src__ = 'Cheetah/Templates/SkeletonPage.tmpl' |
| 42 |
__CHEETAH_srcLastModified__ = 'Tue Mar 14 23:26:16 2017' |
| 43 |
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine' |
| 44 |
|
| 45 |
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple: |
| 46 |
raise AssertionError( |
| 47 |
'This template was compiled with Cheetah version' |
| 48 |
' %s. Templates compiled before version %s must be recompiled.'%( |
| 49 |
__CHEETAH_version__, RequiredCheetahVersion)) |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
class SkeletonPage(_SkeletonPage): |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
def __init__(self, *args, **KWs): |
| 61 |
|
| 62 |
super(SkeletonPage, self).__init__(*args, **KWs) |
| 63 |
if not self._CHEETAH__instanceInitialized: |
| 64 |
cheetahKWArgs = {} |
| 65 |
allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split() |
| 66 |
for k,v in KWs.items(): |
| 67 |
if k in allowedKWs: cheetahKWArgs[k] = v |
| 68 |
self._initCheetahInstance(**cheetahKWArgs) |
| 69 |
|
| 70 |
|
| 71 |
def writeHeadTag(self, **KWS): |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
trans = KWS.get("trans") |
| 77 |
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): |
| 78 |
trans = self.transaction |
| 79 |
if not trans: |
| 80 |
trans = DummyTransaction() |
| 81 |
_dummyTrans = True |
| 82 |
else: _dummyTrans = False |
| 83 |
write = trans.response().write |
| 84 |
SL = self._CHEETAH__searchList |
| 85 |
_filter = self._CHEETAH__currentFilter |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
write(u'''<head> |
| 91 |
<title>''') |
| 92 |
_v = VFSL([locals()]+SL+[globals(), builtin],"title",True) |
| 93 |
if _v is not None: write(_filter(_v, rawExpr=u'$title')) |
| 94 |
write(u'''</title> |
| 95 |
''') |
| 96 |
_v = VFSL([locals()]+SL+[globals(), builtin],"metaTags",True) |
| 97 |
if _v is not None: write(_filter(_v, rawExpr=u'$metaTags')) |
| 98 |
write(u''' |
| 99 |
''') |
| 100 |
_v = VFSL([locals()]+SL+[globals(), builtin],"stylesheetTags",True) |
| 101 |
if _v is not None: write(_filter(_v, rawExpr=u'$stylesheetTags')) |
| 102 |
write(u''' |
| 103 |
''') |
| 104 |
_v = VFSL([locals()]+SL+[globals(), builtin],"javascriptTags",True) |
| 105 |
if _v is not None: write(_filter(_v, rawExpr=u'$javascriptTags')) |
| 106 |
write(u''' |
| 107 |
</head> |
| 108 |
''') |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
return _dummyTrans and trans.response().getvalue() or "" |
| 114 |
|
| 115 |
|
| 116 |
def writeBody(self, **KWS): |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
trans = KWS.get("trans") |
| 122 |
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): |
| 123 |
trans = self.transaction |
| 124 |
if not trans: |
| 125 |
trans = DummyTransaction() |
| 126 |
_dummyTrans = True |
| 127 |
else: _dummyTrans = False |
| 128 |
write = trans.response().write |
| 129 |
SL = self._CHEETAH__searchList |
| 130 |
_filter = self._CHEETAH__currentFilter |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
write(u'''This skeleton page has no flesh. Its body needs to be implemented. |
| 136 |
''') |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
return _dummyTrans and trans.response().getvalue() or "" |
| 142 |
|
| 143 |
|
| 144 |
def respond(self, trans=None): |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): |
| 150 |
trans = self.transaction |
| 151 |
if not trans: |
| 152 |
trans = DummyTransaction() |
| 153 |
_dummyTrans = True |
| 154 |
else: _dummyTrans = False |
| 155 |
write = trans.response().write |
| 156 |
SL = self._CHEETAH__searchList |
| 157 |
_filter = self._CHEETAH__currentFilter |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
_RECACHE_header = False |
| 165 |
_cacheRegion_header = self.getCacheRegion(regionID=u'header', cacheInfo={'type': 2, u'id': u'header'}) |
| 166 |
if _cacheRegion_header.isNew(): |
| 167 |
_RECACHE_header = True |
| 168 |
_cacheItem_header = _cacheRegion_header.getCacheItem(u'header') |
| 169 |
if _cacheItem_header.hasExpired(): |
| 170 |
_RECACHE_header = True |
| 171 |
if (not _RECACHE_header) and _cacheItem_header.getRefreshTime(): |
| 172 |
try: |
| 173 |
_output = _cacheItem_header.renderOutput() |
| 174 |
except KeyError: |
| 175 |
_RECACHE_header = True |
| 176 |
else: |
| 177 |
write(_output) |
| 178 |
del _output |
| 179 |
if _RECACHE_header or not _cacheItem_header.getRefreshTime(): |
| 180 |
_orig_transheader = trans |
| 181 |
trans = _cacheCollector_header = DummyTransaction() |
| 182 |
write = _cacheCollector_header.response().write |
| 183 |
_v = VFSL([locals()]+SL+[globals(), builtin],"docType",True) |
| 184 |
if _v is not None: write(_filter(_v, rawExpr=u'$docType')) |
| 185 |
write(u''' |
| 186 |
''') |
| 187 |
_v = VFSL([locals()]+SL+[globals(), builtin],"htmlTag",True) |
| 188 |
if _v is not None: write(_filter(_v, rawExpr=u'$htmlTag')) |
| 189 |
write(u''' |
| 190 |
<!-- This document was autogenerated by Cheetah (https://cheetahtemplate.org/). |
| 191 |
Do not edit it directly! |
| 192 |
|
| 193 |
Copyright ''') |
| 194 |
_v = VFSL([locals()]+SL+[globals(), builtin],"currentYr",True) |
| 195 |
if _v is not None: write(_filter(_v, rawExpr=u'$currentYr')) |
| 196 |
write(u''' - ''') |
| 197 |
_v = VFSL([locals()]+SL+[globals(), builtin],"siteCopyrightName",True) |
| 198 |
if _v is not None: write(_filter(_v, rawExpr=u'$siteCopyrightName')) |
| 199 |
write(u''' - All Rights Reserved. |
| 200 |
Feel free to copy any javascript or html you like on this site, |
| 201 |
provided you remove all links and/or references to ''') |
| 202 |
_v = VFSL([locals()]+SL+[globals(), builtin],"siteDomainName",True) |
| 203 |
if _v is not None: write(_filter(_v, rawExpr=u'$siteDomainName')) |
| 204 |
write(u''' |
| 205 |
However, please do not copy any content or images without permission. |
| 206 |
|
| 207 |
''') |
| 208 |
_v = VFSL([locals()]+SL+[globals(), builtin],"siteCredits",True) |
| 209 |
if _v is not None: write(_filter(_v, rawExpr=u'$siteCredits')) |
| 210 |
write(u''' |
| 211 |
|
| 212 |
--> |
| 213 |
|
| 214 |
|
| 215 |
''') |
| 216 |
self.writeHeadTag(trans=trans) |
| 217 |
write(u''' |
| 218 |
''') |
| 219 |
trans = _orig_transheader |
| 220 |
write = trans.response().write |
| 221 |
_cacheData = _cacheCollector_header.response().getvalue() |
| 222 |
_cacheItem_header.setData(_cacheData) |
| 223 |
write(_cacheData) |
| 224 |
del _cacheData |
| 225 |
del _cacheCollector_header |
| 226 |
del _orig_transheader |
| 227 |
|
| 228 |
|
| 229 |
write(u''' |
| 230 |
''') |
| 231 |
_v = VFSL([locals()]+SL+[globals(), builtin],"bodyTag",True) |
| 232 |
if _v is not None: write(_filter(_v, rawExpr=u'$bodyTag')) |
| 233 |
write(u''' |
| 234 |
|
| 235 |
''') |
| 236 |
self.writeBody(trans=trans) |
| 237 |
write(u''' |
| 238 |
</body> |
| 239 |
</html> |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
''') |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
return _dummyTrans and trans.response().getvalue() or "" |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
_CHEETAH__instanceInitialized = False |
| 255 |
|
| 256 |
_CHEETAH_version = __CHEETAH_version__ |
| 257 |
|
| 258 |
_CHEETAH_versionTuple = __CHEETAH_versionTuple__ |
| 259 |
|
| 260 |
_CHEETAH_genTime = __CHEETAH_genTime__ |
| 261 |
|
| 262 |
_CHEETAH_genTimestamp = __CHEETAH_genTimestamp__ |
| 263 |
|
| 264 |
_CHEETAH_src = __CHEETAH_src__ |
| 265 |
|
| 266 |
_CHEETAH_srcLastModified = __CHEETAH_srcLastModified__ |
| 267 |
|
| 268 |
_mainCheetahMethod_for_SkeletonPage= u'respond' |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
if not hasattr(SkeletonPage, '_initCheetahAttributes'): |
| 273 |
templateAPIClass = getattr(SkeletonPage, '_CHEETAH_templateClass', Template) |
| 274 |
templateAPIClass._addCheetahPlumbingCodeToClass(SkeletonPage) |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
if __name__ == '__main__': |
| 284 |
from Cheetah.TemplateCmdLineIface import CmdLineIface |
| 285 |
CmdLineIface(templateObj=SkeletonPage()).run() |