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

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: stevenbird
  • Date: 2008-02-14 00:18:01 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:447
graphic for user database schema

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
            self.path = path
145
145
        else:
146
146
            (self.app, self.path) = (common.util.split_path(path))
147
 
        self.user = None
 
147
        self.username = None
148
148
        self.hostname = os.environ['SERVER_NAME']
149
149
        self.headers_in = _http_headers_in_from_cgi()
150
150
        self.headers_out = {}
242
242
        else:
243
243
            return sys.stdin.read(len)
244
244
 
245
 
    def throw_error(self, httpcode, message):
 
245
    def throw_error(self, httpcode):
246
246
        """Writes out an HTTP error of the specified code. Exits the process,
247
247
        so any code following this call will not be executed.
248
248
 
253
253
        httpcode: An HTTP response status code. Pass a constant from the
254
254
        Request class.
255
255
        """
256
 
        raise common.util.IVLEError(httpcode, message)
 
256
        self.status = httpcode
 
257
        self.content_type = "text/html"
 
258
        # Emulate an Apache error
 
259
        self.write("""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 
260
<html><head>
 
261
<title>%d Error</title>
 
262
</head><body>
 
263
<h1>Error</h1>
 
264
<p>A %d error was triggered by a CGI app.</p>
 
265
</body></html>
 
266
""" % (httpcode, httpcode))
 
267
        # Exit the process completely
 
268
        self.flush()
 
269
        sys.exit(httpcode)
257
270
 
258
271
    def throw_redirect(self, location):
259
272
        """Writes out an HTTP redirect to the specified URL. Exits the