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

« back to all changes in this revision

Viewing changes to lib/common/interpret.py

  • Committer: wagrant
  • Date: 2008-07-14 01:31:14 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:851
Give CGIRequest an exception handler which turns any exception into
HTTP headers. interpret reads these, and raises an IVLEJailError, which
dispatch should eventually look at.

This is now enabled in serveservice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from common import studpath
31
31
from common import db
32
 
from common.util import IVLEError
 
32
from common.util import IVLEError, IVLEJailError
33
33
import conf
34
34
import functools
35
35
 
233
233
                split = headers.split('\n', 1)
234
234
 
235
235
        # Is this an internal IVLE error condition?
236
 
        if 'X-IVLE-Error-Code' in cgiflags.headers:
237
 
            raise IVLEError(int(cgiflags.headers['X-IVLE-Error-Code']),
238
 
                            cgiflags.headers['X-IVLE-Error-Message'])
 
236
        hs = cgiflags.headers
 
237
        if 'X-IVLE-Error-Type' in hs:
 
238
            t = hs['X-IVLE-Error-Type']
 
239
            if t == IVLEError.__name__:
 
240
                raise IVLEError(int(hs['X-IVLE-Error-Code']),
 
241
                                hs['X-IVLE-Error-Message'])
 
242
            else:
 
243
                try:
 
244
                    raise IVLEJailError(hs['X-IVLE-Error-Type'],
 
245
                                        hs['X-IVLE-Error-Message'],
 
246
                                        hs['X-IVLE-Error-Info'])
 
247
                except KeyError:
 
248
                    raise IVLEError(500, 'bad error headers written by CGI')
239
249
 
240
250
        # Check to make sure the required headers were written
241
251
        if cgiflags.wrote_html_warning or not cgiflags.gentle: