Ignore:
Timestamp:
Dec 20, 2009, 9:44:15 PM (15 years ago)
Author:
broder
Message:

Get username and state from CherryPy? request

Location:
package_branches/invirt-web/cherrypy-rebased/code
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy-rebased/code/main.fcgi

    r2661 r2669  
    2020    app = cherrypy.tree.mount(InvirtWeb(),
    2121        '/' if dev else '/main.fcgi',
    22         {'/':      {'tools.staticdir.root': static_dir},
     22        {'/':      {'tools.staticdir.root': static_dir,
     23                    'tools.invirtwebstate.on': True},
    2324        '/static': {'tools.staticdir.on': True,
    2425                    'tools.staticdir.dir': static_dir}
  • package_branches/invirt-web/cherrypy-rebased/code/main.py

    r2668 r2669  
    5656    @cherrypy.expose
    5757    @cherrypy.tools.mako(filename="/list.mako")
    58     def list(self, username):
     58    def list(self):
    5959        """Handler for list requests."""
    6060        checkpoint.checkpoint('Getting list dict')
    61         d = getListDict(username, state)
     61        d = getListDict(cherrypy.request.login, cherrypy.request.state)
    6262        checkpoint.checkpoint('Got list dict')
    6363        return d
  • package_branches/invirt-web/cherrypy-rebased/code/view.py

    r2665 r2669  
    66import simplejson
    77import datetime, decimal
     8from invirt.config import structs as config
     9from webcommon import State
    810
    911class MakoHandler(cherrypy.dispatch.LateParamPageHandler):
     
    7981cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login)
    8082
     83def invirtwebstate_init():
     84    """Initialize the cherrypy.request.state object from Invirt"""
     85    cherrypy.request.state = State(cherrypy.request.login)
     86
     87cherrypy.tools.invirtwebstate = cherrypy.Tool('on_start_resource', invirtwebstate_init, priority=100)
     88
    8189class View(object):
    8290    _cp_config = {'tools.mako.directories': [os.path.join(os.path.dirname(__file__),'templates')]}
Note: See TracChangeset for help on using the changeset viewer.