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

« back to all changes in this revision

Viewing changes to ivle/dispatch/__init__.py

  • Committer: Nick Chadwick
  • Date: 2009-03-09 00:15:21 UTC
  • mfrom: (1099.6.4 new-dispatch)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090309001521-dffcygyuyvs2cap0
finished the exercise-ui. It is now ready to be merged with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from ivle.dispatch.request import Request
45
45
import ivle.webapp.security
46
46
from ivle.webapp.base.plugins import ViewPlugin, PublicViewPlugin
47
 
from ivle.webapp.errors import HTTPError, Unauthorized
 
47
from ivle.webapp.base.xhtml import XHTMLView, XHTMLErrorView
 
48
from ivle.webapp.errors import HTTPError, Unauthorized, NotFound
48
49
 
49
50
def generate_route_mapper(view_plugins, attr):
50
51
    """
116
117
            if hasattr(viewcls, 'get_error_view'):
117
118
                errviewcls = viewcls.get_error_view(e)
118
119
            else:
119
 
                errviewcls = None
 
120
                errviewcls = XHTMLView.get_error_view(e)
120
121
 
121
122
            if errviewcls:
122
123
                errview = errviewcls(req, e)
135
136
            req.store.commit()
136
137
            return req.OK
137
138
    else:
138
 
        return req.HTTP_NOT_FOUND # TODO: Prettify.
 
139
        XHTMLErrorView(req, NotFound()).render(req)
 
140
        return req.OK
139
141
 
140
142
def handle_unknown_exception(req, exc_type, exc_value, exc_traceback):
141
143
    """
164
166
        login = req.user.login
165
167
    except AttributeError:
166
168
        login = None
167
 
    try:
168
 
        role = req.user.role
169
 
    except AttributeError:
170
 
        role = None
171
169
 
172
170
    # Log File
173
171
    try:
213
211
 
214
212
    # Error messages are only displayed is the user is NOT a student,
215
213
    # or if there has been a problem logging the error message
216
 
    show_errors = (not publicmode) and ((login and \
217
 
                        str(role) != "student") or logfail)
 
214
    show_errors = (not publicmode) and ((login and req.user.admin) or logfail)
218
215
    req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"                 
219
216
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">                                      
220
217
<html xmlns="http://www.w3.org/1999/xhtml">