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

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: dcoles
  • Date: 2008-08-18 04:34:11 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1021
Database: Adds active column to problem_attempt table.
This allows a group of problem attempts (ie. from previous semesters) to be
marked as 'inactive' and thus counting toward a problem being assessment for
the current semester.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import sys
32
32
import os
33
33
import cgi
 
34
import urllib
 
35
import traceback
34
36
 
35
37
import conf
36
38
import common
160
162
        self.write_html_head_foot = False
161
163
        self.got_common_vars = False
162
164
 
 
165
 
 
166
    def install_error_handler(self):
 
167
        '''Install our exception handler as the default.'''
 
168
        sys.excepthook = self.handle_unknown_exception
 
169
 
163
170
    def __writeheaders(self):
164
171
        """Writes out the HTTP and HTML headers before any real data is
165
172
        written."""
256
263
        """
257
264
        raise common.util.IVLEError(httpcode, message)
258
265
 
 
266
    def handle_unknown_exception(self, exc_type, exc_value, exc_tb):
 
267
        if exc_type is common.util.IVLEError:
 
268
            self.headers_out['X-IVLE-Error-Code'] = exc_value.httpcode
 
269
 
 
270
        self.headers_out['X-IVLE-Error-Type'] = exc_type.__name__
 
271
 
 
272
        try:
 
273
            self.headers_out['X-IVLE-Error-Message'] = exc_value.message
 
274
        except AttributeError:
 
275
            pass
 
276
 
 
277
        self.headers_out['X-IVLE-Error-Info'] = urllib.quote(''.join(
 
278
              traceback.format_exception(exc_type, exc_value, exc_tb)))
 
279
        self.status = 500
 
280
        self.ensure_headers_written()
 
281
        self.write('An internal IVLE error has occurred.')
 
282
        self.flush()
 
283
        sys.exit(self.status)
 
284
 
259
285
    def throw_redirect(self, location):
260
286
        """Writes out an HTTP redirect to the specified URL. Exits the
261
287
        process, so any code following this call will not be executed.