~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-06-24 10:47:38 UTC
  • mfrom: (1288 trunk)
  • mto: (1281.1.8 aufsless)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: grantw@unimelb.edu.au-20090624104738-ezgfy17mjzwz09i3
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
    req.content_type = "text/html"
156
156
    logfile = os.path.join(config['paths']['logs'], 'ivle_error.log')
157
157
    logfail = False
158
 
    try:
159
 
        httpcode = exc_value.httpcode
160
 
        req.status = httpcode
161
 
    except AttributeError:
162
 
        httpcode = None
163
 
        req.status = mod_python.apache.HTTP_INTERNAL_SERVER_ERROR
 
158
    req.status = mod_python.apache.HTTP_INTERNAL_SERVER_ERROR
 
159
 
164
160
    try:
165
161
        publicmode = req.publicmode
166
162
    except AttributeError:
189
185
    # misbehaves (which is currently very easy, if things aren't set up
190
186
    # correctly).
191
187
    # Write the traceback.
192
 
    # If this is a non-4xx IVLEError, get the message and httpcode and
193
 
    # make the error message a bit nicer (but still include the
194
 
    # traceback).
195
 
    # We also need to special-case IVLEJailError, as we can get another
 
188
 
 
189
    # We need to special-case IVLEJailError, as we can get another
196
190
    # almost-exception out of it.
197
 
 
198
 
    codename, msg = None, None
199
 
 
200
191
    if exc_type is util.IVLEJailError:
201
 
        msg = exc_value.type_str + ": " + exc_value.message
202
192
        tb = 'Exception information extracted from IVLEJailError:\n'
203
193
        tb += urllib.unquote(exc_value.info)
204
194
    else:
205
 
        try:
206
 
            codename, msg = req.get_http_codename(httpcode)
207
 
        except AttributeError:
208
 
            pass
209
 
 
210
195
        tb = ''.join(traceback.format_exception(exc_type, exc_value,
211
196
                                                exc_traceback))
212
197
 
213
 
    logging.error('%s\n%s'%(str(msg), tb))
 
198
    logging.error('\n' + tb)
214
199
 
215
200
    # Error messages are only displayed is the user is NOT a student,
216
201
    # or if there has been a problem logging the error message
220
205
<html xmlns="http://www.w3.org/1999/xhtml">
221
206
<head><title>IVLE Internal Server Error</title></head>
222
207
<body>
223
 
<h1>IVLE Internal Server Error""")
224
 
    if show_errors:
225
 
        if codename is not None and \
226
 
           httpcode != mod_python.apache.HTTP_INTERNAL_SERVER_ERROR:
227
 
            req.write(": %s" % cgi.escape(codename))
228
 
 
229
 
    req.write("""</h1>
 
208
<h1>IVLE Internal Server Error</h1>
230
209
<p>An error has occured which is the fault of the IVLE developers or
231
210
administrators. """)
232
211
 
238
217
    req.write("</p>")
239
218
 
240
219
    if show_errors:
241
 
        if msg is not None:
242
 
            req.write("<p>%s</p>\n" % cgi.escape(msg))
243
 
        if httpcode is not None:
244
 
            req.write("<p>(HTTP error code %d)</p>\n" % httpcode)
245
220
        req.write("<h2>Debugging information</h2>")
246
 
 
247
221
        req.write("<pre>\n%s\n</pre>\n"%cgi.escape(tb))
248
222
    req.write("</body></html>")