From d6a12bd1e32e3f9bc63c2c6f1d2d2793a9eee4d2 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 9 Aug 2009 18:45:24 -0400 Subject: [PATCH] Port functions to Mako svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2667 --- code/templates/functions.mako | 41 +++++++++++++++++++++++++++ code/templates/functions.tmpl | 63 ----------------------------------------- code/templates/skeleton.mako | 1 + 3 files changed, 42 insertions(+), 63 deletions(-) create mode 100644 code/templates/functions.mako delete mode 100644 code/templates/functions.tmpl diff --git a/code/templates/functions.mako b/code/templates/functions.mako new file mode 100644 index 0000000..99c0d30 --- /dev/null +++ b/code/templates/functions.mako @@ -0,0 +1,41 @@ +<%page expression_filter="h"/> +<%def name="databaseList(lst, default, onchange, name, id, valueattr, descattr)"> + + + +<%def name="cdromList(default='', onchange=None)"> +${databaseList(sorted(database.CDROM.query(), key=lambda x: x.description), + default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')|n} + + +<%def name="autoList(default='', onchange=None)"> +${databaseList(sorted(database.Autoinstall.query(), key=lambda x: x.description), + default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')|n} + + +<%def name="vmTypeList(default=None)"> +% for vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), ): + +% endfor + + +<%def name="errorRow(value, err)"> +% if err and err.err_field == value: + +${str(err)} + +% endif + diff --git a/code/templates/functions.tmpl b/code/templates/functions.tmpl deleted file mode 100644 index 305b4e8..0000000 --- a/code/templates/functions.tmpl +++ /dev/null @@ -1,63 +0,0 @@ -#filter WebSafe -#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr) - -#end def - -#def cdromList($default="", $onchange=None) -#filter None -$databaseList(sorted($database.CDROM.query(), key=lambda x: x.description), - default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description') -#end filter -#end def - -#def autoList($default="", $onchange=None) -#filter None -$databaseList(sorted($database.Autoinstall.query(), key=lambda x: x.description), - default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description') -#end filter -#end def - -#def vmTypeList($default=None) -#for $vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), ) - -#end for -#end def - -#def addError(txt) -#if $varExists('txt') -#set global $error_text = $error_text + '----\n' + $txt -#else -#set global $error_text = $txt -#end if -#end def - -#def errorRow($value, $err) -#if $err and $err.err_field == $value - -${str($err)} - -#end if -#end def -#filter None -$full_body -#end filter -#end filter diff --git a/code/templates/skeleton.mako b/code/templates/skeleton.mako index 0fd67e3..d602252 100644 --- a/code/templates/skeleton.mako +++ b/code/templates/skeleton.mako @@ -1,4 +1,5 @@ <%page expression_filter="h"/> +<%namespace name="fn" file="functions.mako" inheritable="True"/> -- 1.7.9.5