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

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/browser/__init__.py

MergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    The view for the browser
41
41
    """
42
42
    template = 'template.html'
43
 
    appname = 'files'
 
43
    tab = 'files'
44
44
    help = 'Filesystem/Browser'
45
45
 
46
46
    def authorize(self, req):
67
67
        if localpath is None:
68
68
            raise NotFound()
69
69
 
 
70
        if isinstance(localpath, unicode):
 
71
            localpath = localpath.encode('utf-8')
 
72
 
70
73
        # Start writing data
71
74
 
72
75
        # FIXME: This isn't completely reliable! We're not inside the jail, so we
73
76
        # can't know the type for sure. This is now only used for adding a / to the
74
77
        # end of displayed paths, so I'm leaving this although it will often break.
75
 
        isdir = os.path.isdir(localpath)
 
78
        try:
 
79
            isdir = os.path.isdir(localpath)
 
80
        except OSError:
 
81
            isdir = False
 
82
 
76
83
        ctx['isdir'] = isdir
77
84
        self.gen_path(req, ctx)
78
85
        self.gen_actions(req, ctx)
80
87
        # The page title should contain the name of the file being browsed
81
88
        ctx['title'] = self.path.rsplit('/', 1)[-1]
82
89
 
83
 
        ctx['fileservice_action'] = util.make_path(os.path.join("fileservice", req.path))
84
 
        ctx['filename'] = cgi.escape(req.path)
 
90
        ctx['fileservice_action'] = util.make_path(os.path.join("fileservice",
 
91
                                                                self.path))
 
92
        ctx['filename'] = cgi.escape(self.path)
85
93
 
86
94
    #TODO: Move all this logic into the template
87
95
    def gen_path(self, req, ctx):
170
178
    ]
171
179
 
172
180
    tabs = [
173
 
        ('files', 'Files', 'Gives you access to all of your files and lets '
174
 
         'you download, upload, edit and run them.', 'browser.png', 'files', 1)
 
181
        ('files', 'Files', 'Access and edit your files',
 
182
         'browser.png', 'files', 1)
175
183
    ]
176
184
 
177
185
    cookies = {'clipboard': None}