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

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: William Grant
  • Date: 2009-07-05 07:54:29 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705075429-qyh9midyp0v73gnv
Add export details for the breadcrumb chevron SVG.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
from ivle.webapp.base.plugins import ViewPlugin, PublicViewPlugin
46
46
from ivle.webapp.base.xhtml import XHTMLView, XHTMLErrorView
47
47
from ivle.webapp.errors import HTTPError, Unauthorized, NotFound
48
 
from ivle.webapp.publisher import Publisher, PublishingError
 
48
from ivle.webapp.routing import Router, RoutingError
49
49
from ivle.webapp import ApplicationRoot
50
50
 
51
51
config = ivle.config.Config()
52
52
 
53
 
def generate_publisher(view_plugins, root):
 
53
def generate_router(view_plugins, root):
54
54
    """
55
55
    Build a Mapper object for doing URL matching using 'routes', based on the
56
56
    given plugin registry.
57
57
    """
58
 
    r = Publisher(root=root)
 
58
    r = Router(root=root)
59
59
 
60
60
    r.add_set_switch('api', 'api')
61
61
 
104
104
    if req.publicmode:
105
105
        raise NotImplementedError("no public mode with obtrav yet!")
106
106
 
107
 
    req.publisher = generate_publisher(config.plugin_index[ViewPlugin],
 
107
    req.router = generate_router(config.plugin_index[ViewPlugin],
108
108
                                 ApplicationRoot(req.config, req.store))
109
109
 
110
110
    try:
111
 
        obj, viewcls, subpath = req.publisher.resolve(req.uri.decode('utf-8'))
 
111
        obj, viewcls, subpath = req.router.resolve(req.uri.decode('utf-8'))
112
112
        try:
113
113
            # We 404 if we have a subpath but the view forbids it.
114
114
            if not viewcls.subpath_allowed and subpath:
134
134
                errviewcls = XHTMLView.get_error_view(e)
135
135
 
136
136
            if errviewcls:
137
 
                errview = errviewcls(req, e, obj)
 
137
                errview = errviewcls(req, e)
138
138
                errview.render(req)
139
139
                return req.OK
140
140
            elif e.message:
154
154
        else:
155
155
            req.store.commit()
156
156
            return req.OK
157
 
    except PublishingError, e:
158
 
        req.status = 404
159
 
 
 
157
    except RoutingError, e:
160
158
        if req.user.admin:
161
159
            XHTMLErrorView(req, NotFound('Not found: ' +
162
 
                                         str(e.args)), e[0]).render(req)
 
160
                                         str(e.args))).render(req)
163
161
        else:
164
 
            XHTMLErrorView(req, NotFound(), e[0]).render(req)
 
162
            XHTMLErrorView(req, NotFound()).render(req)
165
163
 
166
164
        return req.OK
167
165