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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

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
 
533
533
    Reads fields: 'path'
534
534
    """
535
535
    paths = fields.getlist('path')
536
 
    user = studpath.url_to_local(req.path)[0]
 
536
    user = util.split_path(req.path)[0]
537
537
    homedir = "/home/%s" % user
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: