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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: William Grant
  • Date: 2009-05-26 02:46:37 UTC
  • Revision ID: grantw@unimelb.edu.au-20090526024637-p0nq01bb3shyarsi
Replace uses of url_to_jailpaths in fileservice with to_home_path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
 
230
230
    Does not mutate req.
231
231
    """
232
 
    (_, _, r) = studpath.url_to_jailpaths(actionpath_to_urlpath(req, path))
 
232
    r = studpath.to_home_path(actionpath_to_urlpath(req, path))
233
233
    if r is None:
234
234
        raise ActionError("Invalid path")
235
235
    return r
421
421
    for datum in data:
422
422
        # Each of the uploaded files
423
423
        filepath = os.path.join(path, datum.filename)
424
 
        (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
 
424
        filepath_local = studpath.to_home_path(filepath)
425
425
        if os.path.isdir(filepath_local):
426
426
            raise ActionError("A directory already exists "
427
427
                    + "with that name")
437
437
            # filename)
438
438
            try:
439
439
                # First get the entire path (within jail)
440
 
                _, _, abspath = studpath.url_to_jailpaths(path)
 
440
                abspath = studpath.to_home_path(path)
441
441
                abspath = os.path.join(os.sep, abspath)
442
442
                zip.unzip(abspath, filedata)
443
443
            except (OSError, IOError):
446
446
                raise ActionError("File '" + e.filename + "' already exists.")
447
447
        else:
448
448
            # Not a zip file
449
 
            (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
 
449
            filepath_local = studpath.to_home_path(filepath)
450
450
            if filepath_local is None:
451
451
                raise ActionError("Invalid path")
452
452
 
538
538
    if len(paths):
539
539
        paths = map(lambda path: actionpath_to_local(req, path), paths)
540
540
    else:
541
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
541
        paths = [studpath.to_home_path(req.path)]
542
542
 
543
543
    # Set all the dirs in home dir world browsable (o+r,o+x)
544
544
    #FIXME: Should really only do those in the direct path not all of the 
568
568
    if len(paths):
569
569
        paths = map(lambda path: actionpath_to_local(req, path), paths)
570
570
    else:
571
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
571
        paths = [studpath.to_home_path(req.path)]
572
572
 
573
573
    try:
574
574
        for path in paths:
665
665
    if len(paths):
666
666
        paths = map(lambda path: actionpath_to_local(req, path), paths)
667
667
    else:
668
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
668
        paths = [studpath.to_home_path(req.path)]
669
669
 
670
670
    try:
671
671
        for path in paths: