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

« back to all changes in this revision

Viewing changes to ivle/webapp/fileservice/__init__.py

  • Committer: William Grant
  • Date: 2009-07-04 13:26:01 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090704132601-ree3krvgipef4uqz
Move the already-ported filesystem views to use subpaths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import ivle.interpret
34
34
from ivle.webapp.base.views import BaseView
35
35
from ivle.webapp.base.plugins import ViewPlugin
36
 
from ivle.webapp.urls import INF
37
36
from ivle.webapp import ApplicationRoot
38
37
 
39
 
class FileserviceFile(object):
40
 
    def __init__(self, root, path):
41
 
        self.root = root
42
 
        self.path = path
43
 
 
44
38
# XXX: Writes to req directly. This is a direct port of the legacy version.
45
39
#      This needs to be rewritten soon.
46
40
class FileserviceView(BaseView):
 
41
    subpath_allowed = True
 
42
 
47
43
    def authorize(self, req):
48
44
        return req.user is not None
49
45
 
50
46
    def render(self, req):
51
47
        """Handler for the File Services application."""
52
 
        if len(self.context.path) == 0:
 
48
        if len(self.path) == 0:
53
49
            # If no path specified, default to the user's home directory
54
50
            req.throw_redirect(req.make_path(os.path.join('fileservice',
55
51
                                                          req.user.login)))
63
59
                                               'services/fileservice'),
64
60
                                  interp_object, gentle=False)
65
61
 
66
 
def root_to_fileservicefile(root, *path):
67
 
    return FileserviceFile(root, os.path.join(*path) if path else '')
 
62
    @property
 
63
    def path(self):
 
64
        return os.path.join(*self.subpath) if self.subpath else ''
68
65
 
69
66
class Plugin(ViewPlugin):
70
 
    forward_routes = [(ApplicationRoot, 'fileservice',
71
 
                       root_to_fileservicefile, INF),
72
 
                      ]
73
 
    views = [(FileserviceFile, '+index', FileserviceView)]
 
67
    views = [(ApplicationRoot, 'fileservice', FileserviceView)]