~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

ivle.dispatch: Throw the routes mapper into req.mapper, and make it explicit.
    This removes the need to manually remove the default 'action' and
    'controller' items.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    Build a Mapper object for doing URL matching using 'routes', based on the
60
60
    plugins config.
61
61
    """
62
 
    m = routes.Mapper()
 
62
    m = routes.Mapper(explicit=True)
63
63
    for pluginstr in plugins_HACK:
64
64
        plugin_path, classname = pluginstr.split('#')
65
65
        # Load the plugin module from somewhere in the Python path
118
118
    # XXX This should be done ONCE per Python process, not per request.
119
119
    # (Wait till WSGI)
120
120
    # XXX No authentication is done here
121
 
    mapper = get_routes_mapper()
122
 
    matchdict = mapper.match(req.uri)
 
121
    req.mapper = get_routes_mapper()
 
122
    matchdict = req.mapper.match(req.uri)
123
123
    if matchdict is not None:
124
124
        viewcls = matchdict['view']
125
125
        # Get the remaining arguments, less 'view', 'action' and 'controller'
126
126
        # (The latter two seem to be built-in, and we don't want them).
127
127
        kwargs = matchdict.copy()
128
128
        del kwargs['view']
129
 
        del kwargs['action']
130
 
        del kwargs['controller']
131
129
        # Instantiate the view, which should be a BaseView class
132
130
        view = viewcls(req, **kwargs)
133
131
        # Render the output