Index: package_branches/invirt-web/cherrypy-rebased/code/main.py =================================================================== --- package_branches/invirt-web/cherrypy-rebased/code/main.py (revision 2677) +++ package_branches/invirt-web/cherrypy-rebased/code/main.py (revision 2678) @@ -150,4 +150,29 @@ return {'request': cherrypy.request, 'kwargs': kwargs} helloworld._cp_config['tools.require_login.on'] = False + + class MachineView(View): + # This is hairy. Fix when CherryPy 3.2 is out. (rename to + # _cp_dispatch, and parse the argument as a list instead of + # string + + def __getattr__(self, name): + try: + machine_id = int(name) + cherrypy.request.params['machine_id'] = machine_id + return self + except ValueError: + return None + + @cherrypy.expose + @cherrypy.tools.mako(filename="/info.mako") + def info(self, machine_id): + """Handler for info on a single VM.""" + machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine + d = infoDict(cherrypy.request.login, cherrypy.request.state, machine) + checkpoint.checkpoint('Got infodict') + return d + index = info + + machine = MachineView() def pathSplit(path): @@ -606,11 +631,4 @@ return d -def info(username, state, path, fields): - """Handler for info on a single VM.""" - machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine - d = infoDict(username, state, machine) - checkpoint.checkpoint('Got infodict') - return templates.info(searchList=[d]) - def unauthFront(_, _2, _3, fields): """Information for unauth'd users.""" @@ -637,5 +655,4 @@ command=command, modify=modify, - info=info, create=create, unauth=unauthFront, Index: package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako =================================================================== --- package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako (revision 2678) +++ package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako (revision 2678) @@ -0,0 +1,102 @@ +<%page expression_filter="h"/> +<%inherit file="skeleton.mako" /> + +<%def name="title()"> +Info on ${machine.name} +%def> + +<%def name="infoTable()"> +
${key}: | ${value} |
We had a problem with your request:
+% elif new_machine: +Successfully modified.
+% endif +% if on: +(To edit ram, disk size, or machine name, turn off the machine first.) +% endif + +%def> + +$key: | $value |
We had a problem with your request:
-#else if $varExists('new_machine') -Successfully modified.
-#end if -#if $on -(To edit ram, disk size, or machine name, turn off the machine first.) -#end if - -#end def - -#def body -