~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-04-28 05:06:00 UTC
  • Revision ID: grantw@unimelb.edu.au-20090428050600-hogd9d6wo7ksyqy8
ivle.database.get_store() now takes a configuration object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
import os
132
132
import cStringIO
133
133
import shutil
134
 
import urllib
135
134
 
136
135
import pysvn
137
136
 
229
228
 
230
229
    Does not mutate req.
231
230
    """
232
 
    r = studpath.to_home_path(actionpath_to_urlpath(req, path))
 
231
    (_, _, r) = studpath.url_to_jailpaths(actionpath_to_urlpath(req, path))
233
232
    if r is None:
234
233
        raise ActionError("Invalid path")
235
234
    return r
421
420
    for datum in data:
422
421
        # Each of the uploaded files
423
422
        filepath = os.path.join(path, datum.filename)
424
 
        filepath_local = studpath.to_home_path(filepath)
 
423
        (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
425
424
        if os.path.isdir(filepath_local):
426
425
            raise ActionError("A directory already exists "
427
426
                    + "with that name")
437
436
            # filename)
438
437
            try:
439
438
                # First get the entire path (within jail)
440
 
                abspath = studpath.to_home_path(path)
 
439
                _, _, abspath = studpath.url_to_jailpaths(path)
441
440
                abspath = os.path.join(os.sep, abspath)
442
441
                zip.unzip(abspath, filedata)
443
442
            except (OSError, IOError):
446
445
                raise ActionError("File '" + e.filename + "' already exists.")
447
446
        else:
448
447
            # Not a zip file
449
 
            filepath_local = studpath.to_home_path(filepath)
 
448
            (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
450
449
            if filepath_local is None:
451
450
                raise ActionError("Invalid path")
452
451
 
533
532
    Reads fields: 'path'
534
533
    """
535
534
    paths = fields.getlist('path')
536
 
    user = util.split_path(req.path)[0]
 
535
    user = studpath.url_to_local(req.path)[0]
537
536
    homedir = "/home/%s" % user
538
537
    if len(paths):
539
538
        paths = map(lambda path: actionpath_to_local(req, path), paths)
540
539
    else:
541
 
        paths = [studpath.to_home_path(req.path)]
 
540
        paths = [studpath.url_to_jailpaths(req.path)[2]]
542
541
 
543
542
    # Set all the dirs in home dir world browsable (o+r,o+x)
544
543
    #FIXME: Should really only do those in the direct path not all of the 
568
567
    if len(paths):
569
568
        paths = map(lambda path: actionpath_to_local(req, path), paths)
570
569
    else:
571
 
        paths = [studpath.to_home_path(req.path)]
 
570
        paths = [studpath.url_to_jailpaths(req.path)[2]]
572
571
 
573
572
    try:
574
573
        for path in paths:
665
664
    if len(paths):
666
665
        paths = map(lambda path: actionpath_to_local(req, path), paths)
667
666
    else:
668
 
        paths = [studpath.to_home_path(req.path)]
 
667
        paths = [studpath.url_to_jailpaths(req.path)[2]]
669
668
 
670
669
    try:
671
670
        for path in paths:
714
713
    paths = fields.getlist('path')
715
714
    if len(paths) != 2:
716
715
        raise ActionError("usage: svncheckout url local-path")
717
 
    url = ivle.conf.svn_addr + "/" + urllib.quote(paths[0])
 
716
    url = ivle.conf.svn_addr + "/" + paths[0]
718
717
    local_path = actionpath_to_local(req, str(paths[1]))
719
718
    try:
720
719
        svnclient.callback_get_login = get_login