~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-02-25 08:36:23 UTC
  • Revision ID: grantw@unimelb.edu.au-20090225083623-h25yf8xk5dui1hsd
Deal with Unicode paths in BrowserView properly again.

Dispatch now gives us a unicode, not a str, so we need to encode it before
we use it as a path. We also need to use the Unicode one when passing it into
Genshi.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):