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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-05-26 02:10:08 UTC
  • Revision ID: grantw@unimelb.edu.au-20090526021008-hnka598yacu5w6da
Always set isdir = False in the file browser template filling.

Previously we used os.path.isdir outside the jail, which was terribly
unreliable and prone to crashing. We should do it properly once we can get
server-side access to the jails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import os.path
35
35
import cgi
36
36
 
37
 
from ivle import studpath
38
37
import ivle.svn
39
38
 
40
39
class BrowserView(XHTMLView):
65
64
                                       'codepress/codepress.js']
66
65
        req.scripts_init = ["browser_init"]
67
66
 
68
 
        _, localpath = studpath.url_to_local(self.path)
69
 
        if localpath is None:
70
 
            raise NotFound()
71
 
 
72
 
        if isinstance(localpath, unicode):
73
 
            localpath = localpath.encode('utf-8')
74
 
 
75
67
        # Start writing data
76
68
 
77
 
        # FIXME: This isn't completely reliable! We're not inside the jail, so we
78
 
        # can't know the type for sure. This is now only used for adding a / to the
79
 
        # end of displayed paths, so I'm leaving this although it will often break.
80
 
        try:
81
 
            isdir = os.path.isdir(localpath)
82
 
        except OSError:
83
 
            isdir = False
 
69
        # TODO: Set this properly. We can't get into the jail from server-side
 
70
        # code at the moment, so we can't determine this.
 
71
        isdir = False
84
72
 
85
73
        revision = ivle.svn.revision_from_string(
86
74
                         req.get_fieldstorage().getfirst('r'))