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

« back to all changes in this revision

Viewing changes to ivle/webapp/base/xhtml.py

Error views are now retrieved from a class method of the view, not the plugin
registry. They also now discriminate based on exception type.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from ivle.webapp.media import media_url
26
26
from ivle.webapp.base.views import BaseView
27
27
from ivle.webapp.base.plugins import OverlayPlugin
 
28
from ivle.webapp.errors import HTTPError
28
29
import ivle.conf
29
30
import ivle.util
30
31
 
143
144
                overlays.append(overlay.render(req))
144
145
        return overlays
145
146
 
 
147
    @classmethod
 
148
    def get_error_view(cls, e):
 
149
        view_map = {HTTPError:    XHTMLErrorView,}
 
150
                    #Unauthorized: XHTMLUnauthorizedView}
 
151
        for exccls in inspect.getmro(type(e)):
 
152
            if exccls in view_map:
 
153
                return view_map[exccls]
 
154
 
146
155
class XHTMLErrorView(XHTMLView):
147
156
    template = 'xhtmlerror.html'
148
157