[113] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | ################################################## |
---|
| 7 | ## DEPENDENCIES |
---|
| 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 |
---|
[205] | 23 | from functions import functions |
---|
[113] | 24 | |
---|
| 25 | ################################################## |
---|
| 26 | ## MODULE CONSTANTS |
---|
| 27 | try: |
---|
| 28 | True, False |
---|
| 29 | except NameError: |
---|
| 30 | True, False = (1==1), (1==0) |
---|
| 31 | VFFSL=valueFromFrameOrSearchList |
---|
| 32 | VFSL=valueFromSearchList |
---|
| 33 | VFN=valueForName |
---|
| 34 | currentTime=time.time |
---|
[184] | 35 | __CHEETAH_version__ = '2.0rc8' |
---|
| 36 | __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 8) |
---|
[205] | 37 | __CHEETAH_genTime__ = 1192883107.2947011 |
---|
| 38 | __CHEETAH_genTimestamp__ = 'Sat Oct 20 08:25:07 2007' |
---|
[113] | 39 | __CHEETAH_src__ = 'skeleton.tmpl' |
---|
[205] | 40 | __CHEETAH_srcLastModified__ = 'Sat Oct 20 08:22:11 2007' |
---|
[113] | 41 | __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine' |
---|
| 42 | |
---|
| 43 | if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple: |
---|
| 44 | raise AssertionError( |
---|
| 45 | 'This template was compiled with Cheetah version' |
---|
| 46 | ' %s. Templates compiled before version %s must be recompiled.'%( |
---|
| 47 | __CHEETAH_version__, RequiredCheetahVersion)) |
---|
| 48 | |
---|
| 49 | ################################################## |
---|
| 50 | ## CLASSES |
---|
| 51 | |
---|
[205] | 52 | class skeleton(functions): |
---|
[113] | 53 | |
---|
| 54 | ################################################## |
---|
| 55 | ## CHEETAH GENERATED METHODS |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | def __init__(self, *args, **KWs): |
---|
| 59 | |
---|
[205] | 60 | functions.__init__(self, *args, **KWs) |
---|
[113] | 61 | if not self._CHEETAH__instanceInitialized: |
---|
| 62 | cheetahKWArgs = {} |
---|
| 63 | allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split() |
---|
| 64 | for k,v in KWs.items(): |
---|
| 65 | if k in allowedKWs: cheetahKWArgs[k] = v |
---|
| 66 | self._initCheetahInstance(**cheetahKWArgs) |
---|
| 67 | |
---|
| 68 | |
---|
[205] | 69 | def full_body(self, **KWS): |
---|
[113] | 70 | |
---|
| 71 | |
---|
| 72 | |
---|
[205] | 73 | ## CHEETAH: generated from #def full_body at line 4, col 1. |
---|
| 74 | trans = KWS.get("trans") |
---|
[113] | 75 | if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): |
---|
| 76 | trans = self.transaction # is None unless self.awake() was called |
---|
| 77 | if not trans: |
---|
| 78 | trans = DummyTransaction() |
---|
| 79 | _dummyTrans = True |
---|
| 80 | else: _dummyTrans = False |
---|
| 81 | write = trans.response().write |
---|
| 82 | SL = self._CHEETAH__searchList |
---|
| 83 | _filter = self._CHEETAH__currentFilter |
---|
| 84 | |
---|
| 85 | ######################################## |
---|
| 86 | ## START - generated method body |
---|
| 87 | |
---|
[205] | 88 | write('''<!DOCTYPE html |
---|
| 89 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
| 90 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
| 91 | <html> |
---|
[184] | 92 | <head><title>''') |
---|
[205] | 93 | _v = VFFSL(SL,"title",True) # '$title' on line 9, col 14 |
---|
| 94 | if _v is not None: write(_filter(_v, rawExpr='$title')) # from line 9, col 14. |
---|
[139] | 95 | write('''</title> |
---|
[184] | 96 | <link href="static/favicon.ico" type="image/x-icon" rel="shortcut icon"> |
---|
| 97 | <link rel="stylesheet" href="static/style.css" type="text/css" /> |
---|
| 98 | <link rel="stylesheet" href="static/layout.css" type="text/css" media="screen" /> |
---|
[205] | 99 | <script type="text/javascript" src="static/prototype.js"></script> |
---|
[139] | 100 | <script type="text/javascript"> |
---|
| 101 | var helpWin = null; |
---|
| 102 | function closeWin(){ |
---|
[184] | 103 | \tif (helpWin != null){ |
---|
| 104 | \t\tif(!helpWin.closed) |
---|
| 105 | \t\t\thelpWin.close(); |
---|
| 106 | \t} |
---|
[139] | 107 | } |
---|
| 108 | |
---|
| 109 | function helppopup(name){ |
---|
| 110 | closeWin() |
---|
[182] | 111 | helpWin = window.open("help?simple=true&subject="+encodeURIComponent(name), "Help", |
---|
[139] | 112 | "status, height = 300, width = 400"); |
---|
| 113 | if (window.focus){helpWin.focus();} |
---|
| 114 | return false; |
---|
| 115 | } |
---|
[205] | 116 | |
---|
| 117 | Ajax.Responders.register({ |
---|
| 118 | onCreate: function(){ |
---|
| 119 | if (Ajax.activeRequestCount > 0) { |
---|
| 120 | document.getElementById("loadingnotice").style.display = \'block\'; |
---|
| 121 | } |
---|
| 122 | }, |
---|
| 123 | onComplete: function(){ |
---|
| 124 | if (Ajax.activeRequestCount == 0) { |
---|
| 125 | document.getElementById("loadingnotice").style.display = \'none\'; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | }); |
---|
| 129 | function replaceFunc(transport) { |
---|
| 130 | try { |
---|
| 131 | d = transport.responseText.evalJSON(); |
---|
| 132 | } catch (e) { |
---|
| 133 | $(\'body\').innerHTML = \'<pre>\'+transport.responseText+\'</pre>\' |
---|
| 134 | return; |
---|
| 135 | } |
---|
| 136 | for(key in d) { |
---|
| 137 | $(key).innerHTML = d[key]; |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | function jsFormSubmit(location, elt){ |
---|
| 142 | new Ajax.Request(location, {method: \'post\', |
---|
| 143 | parameters: Form.serialize(elt)+\'&js=true\', |
---|
| 144 | onSuccess: replaceFunc, |
---|
| 145 | onComplete: function() {Form.enable(elt);} |
---|
| 146 | }); |
---|
| 147 | Form.disable(elt); |
---|
| 148 | return false; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | function rowFormSubmit(elt, retpage){ |
---|
| 152 | new Ajax.Request(\'command\', {method: \'post\', |
---|
| 153 | parameters: Form.serialize(elt)+\'&js=\'+retpage, |
---|
| 154 | onSuccess: replaceFunc |
---|
| 155 | }); |
---|
| 156 | return false; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | window.onload = { |
---|
| 160 | //Fix bug with disabled elements |
---|
| 161 | $''') |
---|
| 162 | _v = 'form' # "$('form')" on line 75, col 4 |
---|
| 163 | if _v is not None: write(_filter(_v, rawExpr="$('form')")) # from line 75, col 4. |
---|
| 164 | write('''.each(Form.enable); |
---|
| 165 | } |
---|
| 166 | |
---|
[139] | 167 | </script> |
---|
| 168 | </head> |
---|
[205] | 169 | <body id="body"> |
---|
| 170 | |
---|
| 171 | <div id="err"> |
---|
[113] | 172 | ''') |
---|
[205] | 173 | if VFFSL(SL,"varExists",False)('error_text'): # generated from line 83, col 1 |
---|
| 174 | write('''<p>STDERR:</p><pre>''') |
---|
| 175 | _v = VFFSL(SL,"error_text",True) # '$error_text' on line 84, col 20 |
---|
| 176 | if _v is not None: write(_filter(_v, rawExpr='$error_text')) # from line 84, col 20. |
---|
| 177 | write('''</pre> |
---|
| 178 | ''') |
---|
| 179 | write('''</div> |
---|
| 180 | |
---|
| 181 | ''') |
---|
| 182 | if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 88, col 1 |
---|
[184] | 183 | write('''<p>[You are logged in as ''') |
---|
[205] | 184 | _v = VFFSL(SL,"user.username",True) # '$user.username' on line 89, col 26 |
---|
| 185 | if _v is not None: write(_filter(_v, rawExpr='$user.username')) # from line 89, col 26. |
---|
[184] | 186 | write('''.]</p> |
---|
[205] | 187 | |
---|
| 188 | <div class="navigation"> |
---|
[187] | 189 | <p><a href="list">List</a> |
---|
[184] | 190 | ''') |
---|
[205] | 191 | if VFFSL(SL,"varExists",False)('machine'): # generated from line 93, col 1 |
---|
[187] | 192 | write('''<a href="info?machine_id=''') |
---|
[205] | 193 | _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 94, col 26 |
---|
| 194 | if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 94, col 26. |
---|
[187] | 195 | write('''">Info</a> |
---|
| 196 | <a href="vnc?machine_id=''') |
---|
[205] | 197 | _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 95, col 25 |
---|
| 198 | if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 95, col 25. |
---|
[187] | 199 | write('''">Console</a> |
---|
| 200 | ''') |
---|
| 201 | write('''<a href="help">Help</a></p> |
---|
| 202 | ''') |
---|
[205] | 203 | write('''</div> |
---|
| 204 | |
---|
| 205 | <div id="loadingnotice" class="loadingnotice">LOADING</div> |
---|
| 206 | <div id="result" class="result"></div> |
---|
| 207 | |
---|
| 208 | ''') |
---|
| 209 | _v = VFFSL(SL,"body",True) # '$body' on line 104, col 1 |
---|
| 210 | if _v is not None: write(_filter(_v, rawExpr='$body')) # from line 104, col 1. |
---|
[184] | 211 | write(''' |
---|
| 212 | ''') |
---|
[205] | 213 | if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 105, col 1 |
---|
[184] | 214 | write('''<hr /> |
---|
| 215 | Questions? Contact <a href="mailto:sipb-xen-dev@mit.edu">sipb-xen-dev@mit.edu</a>. |
---|
| 216 | ''') |
---|
| 217 | write('''</body> |
---|
| 218 | </html> |
---|
| 219 | ''') |
---|
[113] | 220 | |
---|
| 221 | ######################################## |
---|
| 222 | ## END - generated method body |
---|
| 223 | |
---|
| 224 | return _dummyTrans and trans.response().getvalue() or "" |
---|
| 225 | |
---|
[205] | 226 | |
---|
| 227 | def writeBody(self, **KWS): |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | |
---|
| 231 | ## CHEETAH: main method generated for this template |
---|
| 232 | trans = KWS.get("trans") |
---|
| 233 | if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): |
---|
| 234 | trans = self.transaction # is None unless self.awake() was called |
---|
| 235 | if not trans: |
---|
| 236 | trans = DummyTransaction() |
---|
| 237 | _dummyTrans = True |
---|
| 238 | else: _dummyTrans = False |
---|
| 239 | write = trans.response().write |
---|
| 240 | SL = self._CHEETAH__searchList |
---|
| 241 | _filter = self._CHEETAH__currentFilter |
---|
| 242 | |
---|
| 243 | ######################################## |
---|
| 244 | ## START - generated method body |
---|
| 245 | |
---|
| 246 | write(''' |
---|
| 247 | ''') |
---|
| 248 | |
---|
| 249 | ######################################## |
---|
| 250 | ## END - generated method body |
---|
| 251 | |
---|
| 252 | return _dummyTrans and trans.response().getvalue() or "" |
---|
| 253 | |
---|
[113] | 254 | ################################################## |
---|
| 255 | ## CHEETAH GENERATED ATTRIBUTES |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | _CHEETAH__instanceInitialized = False |
---|
| 259 | |
---|
| 260 | _CHEETAH_version = __CHEETAH_version__ |
---|
| 261 | |
---|
| 262 | _CHEETAH_versionTuple = __CHEETAH_versionTuple__ |
---|
| 263 | |
---|
| 264 | _CHEETAH_genTime = __CHEETAH_genTime__ |
---|
| 265 | |
---|
| 266 | _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__ |
---|
| 267 | |
---|
| 268 | _CHEETAH_src = __CHEETAH_src__ |
---|
| 269 | |
---|
| 270 | _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__ |
---|
| 271 | |
---|
[205] | 272 | _mainCheetahMethod_for_skeleton= 'writeBody' |
---|
[113] | 273 | |
---|
| 274 | ## END CLASS DEFINITION |
---|
| 275 | |
---|
| 276 | if not hasattr(skeleton, '_initCheetahAttributes'): |
---|
| 277 | templateAPIClass = getattr(skeleton, '_CHEETAH_templateClass', Template) |
---|
| 278 | templateAPIClass._addCheetahPlumbingCodeToClass(skeleton) |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | # CHEETAH was developed by Tavis Rudd and Mike Orr |
---|
| 282 | # with code, advice and input from many other volunteers. |
---|
| 283 | # For more information visit http://www.CheetahTemplate.org/ |
---|
| 284 | |
---|
| 285 | ################################################## |
---|
| 286 | ## if run from command line: |
---|
| 287 | if __name__ == '__main__': |
---|
| 288 | from Cheetah.TemplateCmdLineIface import CmdLineIface |
---|
| 289 | CmdLineIface(templateObj=skeleton()).run() |
---|
| 290 | |
---|
| 291 | |
---|