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

« back to all changes in this revision

Viewing changes to ivle/cgirequest.py

  • Committer: Matt Giuca
  • Date: 2009-05-12 15:08:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1247.
  • Revision ID: matt.giuca@gmail.com-20090512150845-fg480l1qh7le0ypz
ivle-fetchsubmissions: In a stunningly awful hack, detects pre-Python2.6 and
    changes make_zip to behave correctly for the awful restriction in zipfile
    that you can't add directories.
    (Stops trying to add directories, and hacks in the footer writing if there
    is an empty file).

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