#filter WebSafe
#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr)
<select name="$name" id="$id"#slurp
#if $onchange is not None
onchange="$onchange"#slurp
#end if
>
  <option #slurp
#if $default then '' else 'selected'
 value="">None</option>
  #for $item in $lst
  <option #slurp
#if $default == getattr(item, valueattr) then 'selected' else ''
 value="${getattr(item, valueattr)}">
    ${getattr(item, descattr)}
  </option>
  #end for
</select>
#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'), )
<label>
   <input #slurp
#if $default == $vmtype[0] then 'checked' else ''
 type="radio" name="vmtype" value="${vmtype[0]}">${vmtype[1]}</input>
</label>
#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
<tr>
<td class="error" colspan="2">${str($err)}</td>
</tr>
#end if
#end def
#filter None
$full_body
#end filter
#end filter
