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

« back to all changes in this revision

Viewing changes to src/common/studpath.py

  • Committer: mattgiuca
  • Date: 2007-12-19 06:01:34 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:85
common/studpath.py: Added url_to_jailpaths.
apps/server: Rewrote parts to now get the UserID and paths relative to jail,
    and pass those off to the interpreter. The interpreter is no longer
    python, but one relative to IVLE (our trampoline). (Currently a test one).
Added bin/tramptest trampoline, called by server temporarily. Just prints out
    its arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    urlpath: Part of the URL, but only the part *after* the application. For
38
38
    instance, given the URL "/ivle/browse/joe/home/mydir/myfile", urlpath will
39
39
    be just "joe/home/mydir/myfile". The expected result is something like
40
 
    ("joe", "/home/informatics/jails/joe/home/svn/mydir/myfile").
 
40
    ("joe", "/home/informatics/jails/joe/home/joe/home/mydir/myfile").
41
41
    Note that the actual location is not guaranteed by this interface (this
42
42
    function serves as a single point of control as to how URLs map onto
43
43
    student directories).
59
59
    path = os.path.join(conf.student_dir, user, 'home', urlpath)
60
60
 
61
61
    return (user, path)
 
62
 
 
63
def url_to_jailpaths(urlpath):
 
64
    """Given a URL path (part of a URL query string), returns a tuple of
 
65
        * the username of the student whose directory is being browsed
 
66
        * the path where the jail will be located relative to conf.student_dir
 
67
          (the jail directory relative to the system jails root).
 
68
        * the path of the file relative to the jail.
 
69
 
 
70
    urlpath: See urlpath in url_to_local.
 
71
 
 
72
    >>> url_to_jailpaths("joe/home/mydir/myfile")
 
73
    ("joe", "joe", "home/joe/home/mydir/myfile")
 
74
 
 
75
    >>> url_to_jailpaths("")
 
76
    (None, None, None)
 
77
    """
 
78
    # Note: User can be a group name. There is absolutely no difference in our
 
79
    # current directory scheme.
 
80
    (user, subpath) = util.split_path(urlpath)
 
81
    if user is None: return (None, None, None)
 
82
 
 
83
    path = os.path.join('home', urlpath)
 
84
 
 
85
    return (user, user, path)