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

« back to all changes in this revision

Viewing changes to ivle/cgirequest.py

  • Committer: Matt Giuca
  • Date: 2009-04-28 11:19:03 UTC
  • Revision ID: matt.giuca@gmail.com-20090428111903-murkoqeljahrp2d8
usrmgt-server: Removed all references to ivle.conf. Now uses the config
    object.
    (I created a global variable, config, just for the outermost functions to
    use. All of the other functions still use an argument version of config,
    for testing purposes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
        self.uri = os.environ['SCRIPT_NAME'] + os.environ['PATH_INFO']
139
139
        # Split the given path into the app (top-level dir) and sub-path
140
140
        # (after first stripping away the root directory)
 
141
        path = self.unmake_path(self.uri)
141
142
        if self.publicmode:
142
143
            self.app = None
143
 
            (_, self.path) = (ivle.util.split_path(self.uri))
 
144
            (_, self.path) = (ivle.util.split_path(path))
144
145
        else:
145
 
            (self.app, self.path) = (ivle.util.split_path(self.uri))
 
146
            (self.app, self.path) = (ivle.util.split_path(path))
146
147
        self.user = None
147
148
        self.hostname = os.environ['SERVER_NAME']
148
149
        self.headers_in = _http_headers_in_from_cgi()
272
273
        self.flush()
273
274
        sys.exit(self.status)
274
275
 
 
276
    def unmake_path(self, path):
 
277
        """Strip the IVLE URL prefix from the given path, if present.
 
278
 
 
279
        Also normalises the path.
 
280
        """
 
281
        path = os.path.normpath(path)
 
282
        root = os.path.normpath(ivle.conf.root_dir)
 
283
 
 
284
        if path.startswith(root):
 
285
            path = path[len(root):]
 
286
            # Take out the slash as well
 
287
            if len(path) > 0 and path[0] == os.sep:
 
288
                path = path[1:]
 
289
 
 
290
        return path
 
291
 
275
292
    def get_session(self):
276
293
        """Returns a mod_python Session object for this request.
277
294
        Note that this is dependent on mod_python and may need to change