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

« back to all changes in this revision

Viewing changes to www/dispatch/request.py

  • Committer: mattgiuca
  • Date: 2007-12-20 05:25:03 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:103
Fix to Makefile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import common.util
27
27
import mod_python
28
 
from mod_python import (util, Session)
29
28
 
30
29
class Request:
31
30
    """An IVLE request object. This is presented to the IVLE apps as a way of
32
31
    interacting with the web server and the dispatcher.
33
32
 
34
33
    Request object attributes:
35
 
        method (read)
36
 
            String. The request method (eg. 'GET', 'POST', etc)
37
34
        uri (read)
38
35
            String. The path portion of the URI.
39
36
        app (read)
42
39
            String. The path specified in the URL *not including* the
43
40
            application or the IVLE location prefix. eg. a URL of
44
41
            "/ivle/files/joe/myfiles" has a path of "joe/myfiles".
45
 
        username (read)
46
 
            String. Login name of the user who is currently logged in, or
47
 
            None.
48
 
        headers_in (read)
49
 
            Table object representing headers sent by the client.
50
 
        headers_out (read, can be written to)
51
 
            Table object representing headers to be sent to the client.
52
42
 
53
43
        status (write)
54
44
            Int. Response status number. Use one of the status codes defined
61
51
        title (write)
62
52
            String. HTML page title. Used if write_html_head_foot is True, in
63
53
            the HTML title element text.
64
 
        styles (write)
65
 
            List of strings. Write a list of URLs to CSS files here, and they
66
 
            will be incorporated as <link rel="stylesheet" type="text/css">
67
 
            elements in the head, if write_html_head_foot is True.
68
 
            URLs should be relative to the IVLE root; they will be fixed up
69
 
            to be site-relative.
70
 
        scripts (write)
71
 
            List of strings. Write a list of URLs to JS files here, and they
72
 
            will be incorporated as <script type="text/javascript"> elements
73
 
            in the head, if write_html_head_foot is True.
74
 
            URLs should be relative to the IVLE root; they will be fixed up
75
 
            to be site-relative.
76
54
        write_html_head_foot (write)
77
55
            Boolean. If True, dispatch assumes that this is an XHTML page, and
78
56
            will immediately write a full HTML head, open the body element,
159
137
        self.headers_written = False
160
138
 
161
139
        # Inherit values for the input members
162
 
        self.method = req.method
163
140
        self.uri = req.uri
164
141
        # Split the given path into the app (top-level dir) and sub-path
165
142
        # (after first stripping away the root directory)
166
143
        (self.app, self.path) = (
167
144
            common.util.split_path(common.util.unmake_path(req.uri)))
168
 
        self.username = None
169
 
        self.headers_in = req.headers_in
170
 
        self.headers_out = req.headers_out
171
145
 
172
146
        # Default values for the output members
173
 
        self.status = Request.HTTP_OK
 
147
        self.status = Request.OK
174
148
        self.content_type = None        # Use Apache's default
175
149
        self.location = None
176
150
        self.title = None     # Will be set by dispatch before passing to app
177
 
        self.styles = []
178
 
        self.scripts = []
179
151
        self.write_html_head_foot = False
180
152
 
181
153
    def __writeheaders(self):
243
215
        Request class.
244
216
        """
245
217
        mod_python.util.redirect(self.apache_req, location)
246
 
 
247
 
    def get_session(self):
248
 
        """Returns a mod_python Session object for this request.
249
 
        Note that this is dependent on mod_python and may need to change
250
 
        interface if porting away from mod_python."""
251
 
        # Cache the session object
252
 
        if not hasattr(self, 'session'):
253
 
            self.session = Session.Session(self.apache_req)
254
 
        return self.session
255
 
 
256
 
    def get_fieldstorage(self):
257
 
        """Returns a mod_python FieldStorage object for this request.
258
 
        Note that this is dependent on mod_python and may need to change
259
 
        interface if porting away from mod_python."""
260
 
        # Cache the fieldstorage object
261
 
        if not hasattr(self, 'fields'):
262
 
            self.fields = util.FieldStorage(self.apache_req)
263
 
        return self.fields