Index: trunk/web/templates/main.py
===================================================================
--- trunk/web/templates/main.py	(revision 138)
+++ trunk/web/templates/main.py	(revision 139)
@@ -25,4 +25,12 @@
     pass
 
+def helppopup(subj):
+    return '<span class="helplink"><a href="help?subject='+subj+'&amp;simple=true" target="_blank" onclick="return helppopup(\''+subj+'\')">(?)</a></span>'
+
+
+global_dict = {}
+global_dict['helppopup'] = helppopup
+
+
 # ... and stolen from xend/uuid.py
 def randomUUID():
@@ -48,5 +56,5 @@
 def error(op, user, fields, err):
     d = dict(op=op, user=user, errorMessage=str(err))
-    print Template(file='error.tmpl', searchList=d);
+    print Template(file='error.tmpl', searchList=[d, global_dict]);
 
 def validMachineName(name):
@@ -268,5 +276,5 @@
              machine=machine)
     print Template(file='create.tmpl',
-                   searchList=d);
+                   searchList=[d, global_dict]);
 
 def listVms(user, fields):
@@ -282,6 +290,5 @@
             has_vnc[m.name] = True
         else:
-            help_name = 'paravm_console'
-            has_vnc[m.name] = 'ParaVM <span class="helplink"><a href="help?subject=%s&amp;simple=true" target="_blank" onclick="return helppopup(\'%s\')">(?)</a></span>' % (help_name, help_name)
+            has_vnc[m.name] = "ParaVM"+helppopup("paravm_console")
     #     for m in machines:
     #         status = statusInfo(m)
@@ -295,5 +302,5 @@
              uptimes=uptimes,
              cdroms=CDROM.select())
-    print Template(file='list.tmpl', searchList=d)
+    print Template(file='list.tmpl', searchList=[d, global_dict])
 
 def testMachineId(user, machineId, exists=True):
@@ -346,5 +353,5 @@
              authtoken=token)
     print Template(file='vnc.tmpl',
-                   searchList=d)
+                   searchList=[d, global_dict])
 
 def getNicInfo(data_dict, machine):
@@ -421,8 +428,29 @@
              command=action,
              machine=machine)
-    print Template(file="command.tmpl", searchList=d)
+    print Template(file="command.tmpl", searchList=[d, global_dict])
         
 def modify(user, fields):
     machine = testMachineId(user, fields.getfirst('machine_id'))
+    
+def help(user, fields):
+    simple = fields.getfirst('simple')
+    subjects = fields.getlist('subject')
+    
+    mapping = dict(paravm_console="""
+ParaVM machines do not support console access over VNC.  To access
+these machines, you either need to boot with a liveCD and ssh in or
+hope that the sipb-xen maintainers add support for serial consoles.""",
+                   hvm_paravm="""
+HVM machines use the virtualization features of the processor, while
+ParaVM machines use Xen's emulation of virtualization features.  You
+want an HVM virtualized machine.""",
+                   cpu_weight="""Don't ask us!  We're as mystified as you are.""")
+    
+    d = dict(user=user,
+             simple=simple,
+             subjects=subjects,
+             mapping=mapping)
+    
+    print Template(file="help.tmpl", searchList=[d, global_dict])
     
 
@@ -452,5 +480,5 @@
                       'DISK_INFO',
                       ('state', 'state (xen format)'),
-                      ('cpu_weight', 'CPU weight'),
+                      ('cpu_weight', 'CPU weight'+helppopup('cpu_weight')),
                       ('on_reboot', 'Action on VM reboot'),
                       ('on_poweroff', 'Action on VM poweroff'),
@@ -497,5 +525,5 @@
              fields = fields)
     print Template(file='info.tmpl',
-                   searchList=d)
+                   searchList=[d, global_dict])
 
 mapping = dict(list=listVms,
@@ -504,5 +532,6 @@
                modify=modify,
                info=info,
-               create=create)
+               create=create,
+               help=help)
 
 if __name__ == '__main__':
@@ -513,5 +542,4 @@
         email = 'moo@cow.com'
     u = User()
-    connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
     operation = os.environ.get('PATH_INFO', '')
     if not operation:
@@ -528,4 +556,6 @@
                           error(operation, u, e,
                                 "Invalid operation '%s'" % operation))
+    if fun not in (help, ):
+        connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
     try:
         fun(u, fields)
