conf_file = os.path.join(base_dir, 'main.conf')
app = cherrypy.tree.mount(InvirtWeb(),
'/' if dev else '/main.fcgi',
- {'/': {'tools.staticdir.root': static_dir},
+ {'/': {'tools.staticdir.root': static_dir,
+ 'tools.invirtwebstate.on': True},
'/static': {'tools.staticdir.on': True,
'tools.staticdir.dir': static_dir}
})
@cherrypy.expose
@cherrypy.tools.mako(filename="/list.mako")
- def list(self, username):
+ def list(self):
"""Handler for list requests."""
checkpoint.checkpoint('Getting list dict')
- d = getListDict(username, state)
+ d = getListDict(cherrypy.request.login, cherrypy.request.state)
checkpoint.checkpoint('Got list dict')
return d
index=list
from mako.lookup import TemplateLookup
import simplejson
import datetime, decimal
+from invirt.config import structs as config
+from webcommon import State
class MakoHandler(cherrypy.dispatch.LateParamPageHandler):
"""Callable which sets response.body."""
cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login)
+def invirtwebstate_init():
+ """Initialize the cherrypy.request.state object from Invirt"""
+ cherrypy.request.state = State(cherrypy.request.login)
+
+cherrypy.tools.invirtwebstate = cherrypy.Tool('on_start_resource', invirtwebstate_init, priority=100)
+
class View(object):
_cp_config = {'tools.mako.directories': [os.path.join(os.path.dirname(__file__),'templates')]}