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

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: mattgiuca
  • Date: 2008-04-17 07:24:01 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:736
Added new script "marks.py" which computes the marks for all students and outputs it as a CSV file.
This borrows a lot of code from tutorial/__init__.py which should be factored out.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        path = common.util.unmake_path(self.uri)
142
142
        if self.publicmode:
143
143
            self.app = None
144
 
            self.path = path
 
144
            (_, self.path) = (common.util.split_path(path))
145
145
        else:
146
146
            (self.app, self.path) = (common.util.split_path(path))
147
147
        self.user = None
242
242
        else:
243
243
            return sys.stdin.read(len)
244
244
 
245
 
    def throw_error(self, httpcode):
 
245
    def throw_error(self, httpcode, message):
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
 
        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)
 
256
        raise common.util.IVLEError(httpcode, message)
270
257
 
271
258
    def throw_redirect(self, location):
272
259
        """Writes out an HTTP redirect to the specified URL. Exits the