X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/01cd9908731ffbf23f58fde2b64153a35e950a80..a6bc598397e68ca5b7c0571341da3aa81617a327:/code/view.py?ds=inline diff --git a/code/view.py b/code/view.py index 6c9caf8..4135e24 100644 --- a/code/view.py +++ b/code/view.py @@ -10,7 +10,7 @@ from invirt.config import structs as config from webcommon import State class MakoHandler(cherrypy.dispatch.LateParamPageHandler): - """Callable which sets response.body.""" + """Callable which processes a dictionary, returning the rendered body.""" def __init__(self, template, next_handler, content_type='text/html; charset=utf-8'): self.template = template @@ -52,13 +52,10 @@ class MakoLoader(object): imports=[]): cherrypy.request.lookup = lookup = self.get_lookup(directories, module_directory, collection_size, imports) - - # Replace the current handler. cherrypy.request.template = t = lookup.get_template(filename) cherrypy.request.handler = MakoHandler(t, cherrypy.request.handler, content_type) -main = MakoLoader() -cherrypy.tools.mako = cherrypy.Tool('on_start_resource', main) +cherrypy.tools.mako = cherrypy.Tool('on_start_resource', MakoLoader()) def revertStandardError(): """Move stderr to stdout, and return the contents of the old stderr.""" @@ -101,9 +98,6 @@ def jsonify_tool_callback(*args, **kwargs): cherrypy.tools.jsonify = cherrypy.Tool('before_finalize', jsonify_tool_callback, priority=30) -def external_remote_user_login(): - pass - def require_login(): """If the user isn't logged in, raise 403 with an error.""" if cherrypy.request.login is False: @@ -121,7 +115,15 @@ def require_POST(): cherrypy.tools.require_POST = cherrypy.Tool('on_start_resource', require_POST, priority=150) def remote_user_login(): - """Get the current user based on the SSL or GSSAPI environment variables""" + """Get the current user based on the SSL or GSSAPI environment +variables and store it in the request object's login variable. This +conforms to the CherryPy API: +http://www.cherrypy.org/wiki/RequestObject#login + +If the user is logged in successfully, cherrypy.request.login is set +to the username. If the user failed to log in, cherrypy.request.login +is set to False. If the user did not attempt authentication, +cherrypy.request.login is set to None.""" environ = cherrypy.request.wsgi_environ user = environ.get('REMOTE_USER') if user is None: