Source code for uw.local.grad.webui.delegate

"""Convenient URL delegators.

These are used to build up the URL structure of the application by analyzing
an URL path arc as the ID of an application.
"""

from uw.web.wsgi.delegate import *

from ..db.unitapp import UnitApplication

[docs]def app_from_arc (arc, cursor, **params): """URL path arc parser for application IDs. Takes the path arc as an appl_id and converts it into a :class:`uw.local.grad.db.unitapp.UnitApplication`. """ if arc is None: return None row = cursor.unitapp_by_id (appl_id=arc) return None if row is None else UnitApplication (cursor, row)
[docs]def app_delegate (dir_handler, arc_handler): """WSGI URL delegator based on application ID. :param dir_handler: the WSGI handler for requests for the root. :param arc_handler: the WSGI handler for non-root requests. Converts the URL path arc into an application and looks up that application in the database. """ return delegate_value ('unitapp', dir_handler, always (arc_handler), convert_arc=app_from_arc)