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

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: dcoles
  • Date: 2008-07-02 04:11:34 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:799
Setup: Added 3rd party (wgrant) packages for NLTK and matplotlib without TeX 
dependency. Also fixed typos.

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
36
34
 
37
35
import conf
38
36
import common
162
160
        self.write_html_head_foot = False
163
161
        self.got_common_vars = False
164
162
 
165
 
 
166
 
    def install_error_handler(self):
167
 
        '''Install our exception handler as the default.'''
168
 
        sys.excepthook = self.handle_unknown_exception
169
 
 
170
163
    def __writeheaders(self):
171
164
        """Writes out the HTTP and HTML headers before any real data is
172
165
        written."""
263
256
        """
264
257
        raise common.util.IVLEError(httpcode, message)
265
258
 
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
 
 
285
259
    def throw_redirect(self, location):
286
260
        """Writes out an HTTP redirect to the specified URL. Exits the
287
261
        process, so any code following this call will not be executed.