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

« back to all changes in this revision

Viewing changes to src/dispatch/request.py

  • Committer: mattgiuca
  • Date: 2007-12-14 03:30:16 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:55
dispatch: request - added some new functions for exiting with an error or
    redirect.
    Made use of these wherever possible.
apps/server: Abstracted out some code.
Added common/studpath.py: For translating URLs into student machine paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
# object.
25
25
 
26
26
import common.util
 
27
import mod_python
27
28
 
28
29
class Request:
29
30
    """An IVLE request object. This is presented to the IVLE apps as a way of
175
176
        """Sends the named file directly to the client."""
176
177
        self.apache_req.sendfile(filename)
177
178
 
 
179
    def throw_error(self, httpcode):
 
180
        """Writes out an HTTP error of the specified code. Raises an exception
 
181
        which is caught by the dispatch or web server, so any code following
 
182
        this call will not be executed.
 
183
 
 
184
        httpcode: An HTTP response status code. Pass a constant from the
 
185
        Request class.
 
186
        """
 
187
        raise mod_python.apache.SERVER_RETURN, httpcode
 
188
 
 
189
    def throw_redirect(self, location):
 
190
        """Writes out an HTTP redirect to the specified URL. Raises an
 
191
        exception which is caught by the dispatch or web server, so any
 
192
        code following this call will not be executed.
 
193
 
 
194
        httpcode: An HTTP response status code. Pass a constant from the
 
195
        Request class.
 
196
        """
 
197
        mod_python.util.redirect(self.apache_req, location)