Index: /package_branches/invirt-web/cherrypy-rebased/code/controls.py
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/controls.py	(revision 2683)
+++ /package_branches/invirt-web/cherrypy-rebased/code/controls.py	(revision 2684)
@@ -205,15 +205,16 @@
         raise
 
-def commandResult(username, state, fields):
+def commandResult(username, state, command_name, machine_id, fields):
     start_time = 0
-    machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine
-    action = fields.getfirst('action')
-    cdrom = fields.getfirst('cdrom')
+    machine = validation.Validate(username, state, machine_id=machine_id).machine
+    action = command_name
+    cdrom = fields.get('cdrom')
+    if not cdrom:
+        cdrom = None
     if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one():
         raise CodeError("Invalid cdrom type '%s'" % cdrom)    
-    if action not in ('Reboot', 'Power on', 'Power off', 'Shutdown', 
-                      'Delete VM'):
+    if action not in "reboot create destroy shutdown delete".split(" "):
         raise CodeError("Invalid action '%s'" % action)
-    if action == 'Reboot':
+    if action == 'reboot':
         if cdrom is not None:
             out, err = remctl('control', machine.name, 'reboot', cdrom,
@@ -231,5 +232,5 @@
                 raise CodeError('ERROR on remctl')
                 
-    elif action == 'Power on':
+    elif action == 'create':
         if validation.maxMemory(username, state, machine) < machine.memory:
             raise InvalidInput('action', 'Power on',
@@ -237,5 +238,5 @@
                                "to turn on this machine.")
         bootMachine(machine, cdrom)
-    elif action == 'Power off':
+    elif action == 'destroy':
         out, err = remctl('control', machine.name, 'destroy', err=True)
         if err:
@@ -247,5 +248,5 @@
                 print >> sys.stderr, err
                 raise CodeError('ERROR on remctl')
-    elif action == 'Shutdown':
+    elif action == 'shutdown':
         out, err = remctl('control', machine.name, 'shutdown', err=True)
         if err:
@@ -257,5 +258,5 @@
                 print >> sys.stderr, err
                 raise CodeError('ERROR on remctl')
-    elif action == 'Delete VM':
+    elif action == 'delete':
         deleteVM(machine)
 
Index: /package_branches/invirt-web/cherrypy-rebased/code/main.py
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/main.py	(revision 2683)
+++ /package_branches/invirt-web/cherrypy-rebased/code/main.py	(revision 2684)
@@ -59,8 +59,10 @@
     @cherrypy.expose
     @cherrypy.tools.mako(filename="/list.mako")
-    def list(self):
+    def list(self, result=None):
         """Handler for list requests."""
         checkpoint.checkpoint('Getting list dict')
         d = getListDict(cherrypy.request.login, cherrypy.request.state)
+        if result is not None:
+            d['result'] = result
         checkpoint.checkpoint('Got list dict')
         return d
@@ -215,4 +217,31 @@
                      authtoken=token)
             return d
+        @cherrypy.expose
+        @cherrypy.tools.mako(filename="/command.mako")
+        def command(self, command_name, machine_id, **kwargs):
+            """Handler for running commands like boot and delete on a VM."""
+            if cherrypy.request.method != "POST":
+                raise InvalidInput("request.method", command_name, "You must execute commands via POST")
+            back = kwargs.get('back', None)
+            try:
+                d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs)
+                if d['command'] == 'Delete VM':
+                    back = 'list'
+            except InvalidInput, err:
+                if not back:
+                    raise
+                print >> sys.stderr, err
+                result = err
+            else:
+                result = 'Success!'
+                if not back:
+                    return d
+            if back == 'list':
+                cherrypy.request.state.clear() #Changed global state
+                raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result))
+            elif back == 'info':
+                raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303)
+            else:
+                raise InvalidInput('back', back, 'Not a known back page.')
 
     machine = MachineView()
@@ -432,33 +461,4 @@
     return disk_fields
 
-def command(username, state, path, fields):
-    """Handler for running commands like boot and delete on a VM."""
-    back = fields.getfirst('back')
-    try:
-        d = controls.commandResult(username, state, fields)
-        if d['command'] == 'Delete VM':
-            back = 'list'
-    except InvalidInput, err:
-        if not back:
-            raise
-        print >> sys.stderr, err
-        result = err
-    else:
-        result = 'Success!'
-        if not back:
-            return templates.command(searchList=[d])
-    if back == 'list':
-        state.clear() #Changed global state
-        d = getListDict(username, state)
-        d['result'] = result
-        return templates.list(searchList=[d])
-    elif back == 'info':
-        machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine
-        return ({'Status': '303 See Other',
-                 'Location': 'info?machine_id=%d' % machine.machine_id},
-                "You shouldn't see this message.")
-    else:
-        raise InvalidInput('back', back, 'Not a known back page.')
-
 def modifyDict(username, state, fields):
     """Modify a machine as specified by CGI arguments.
@@ -652,5 +652,4 @@
 
 mapping = dict(
-               command=command,
                modify=modify,
                create=create,
Index: /package_branches/invirt-web/cherrypy-rebased/code/templates/command.mako
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/templates/command.mako	(revision 2684)
+++ /package_branches/invirt-web/cherrypy-rebased/code/templates/command.mako	(revision 2684)
@@ -0,0 +1,9 @@
+<%page expression_filter="h" />
+<%inherit file="skeleton.mako" />
+
+<%def name="title()">
+$command ${machine.name}
+</%def>
+
+<p>${command} ${machine.name} was successful.</p>
+<p><a href="list">Return</a></p>
Index: ckage_branches/invirt-web/cherrypy-rebased/code/templates/command.tmpl
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/templates/command.tmpl	(revision 2683)
+++ 	(revision )
@@ -1,16 +1,0 @@
-#from skeleton import skeleton
-#extends skeleton
-
-#def title
-$command $machine.name
-#end def
-
-
-#def body
-<p>$command ${machine.name} was successful.</p>
-#if $command == "Delete VM" or True
-<p><a href="list">Return</a></p>
-#else
-<p><a href="info?machine_id=${machine.machine_id}">Return</a></p>
-#end if
-#end def
Index: /package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako	(revision 2683)
+++ /package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako	(revision 2684)
@@ -29,5 +29,5 @@
 <%def name="command_button(title, value, cdrom=False, extra='')">
 <form action="machine/${machine.machine_id}/command/${value}" method="POST">
-  <input type="hidden" name="back" value="machine/${machine.machine_id}/info" />
+  <input type="hidden" name="back" value="info" />
   <input type="submit" class="button" name="action" value="${title}" ${extra | n}/>
 % if cdrom:
Index: /package_branches/invirt-web/cherrypy-rebased/code/templates/list.mako
===================================================================
--- /package_branches/invirt-web/cherrypy-rebased/code/templates/list.mako	(revision 2683)
+++ /package_branches/invirt-web/cherrypy-rebased/code/templates/list.mako	(revision 2684)
@@ -85,9 +85,9 @@
       <tr> 
 	<td rowspan="2">
-	  <form action="command" method="post">
+	  <form action="machine/${machine.machine_id}/command/${'shutdown' if machine.uptime else 'create'}" method="post">
 	    <input type="hidden" name="back" value="list"/>
 	    <input type="hidden" name="machine_id"
 		   value="${machine.machine_id}"/>
-<input type="submit" class="power ${'on' if machine.uptime else 'off'}" name="action" value="${'Power off' if machine.uptime else 'Power on'}"\
+<input type="submit" class="power ${'on' if machine.uptime else 'off'}" name="action" value="${'Shutdown' if machine.uptime else 'Power on'}"\
 % if machine.uptime:
  onclick="return confirm('Are you sure you want to power off this VM?');"
