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

« back to all changes in this revision

Viewing changes to ivle/webapp/media.py

  • Committer: William Grant
  • Date: 2009-07-05 07:54:29 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-20090705075429-qyh9midyp0v73gnv
Add export details for the breadcrumb chevron SVG.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle.webapp.base.views import BaseView
29
29
from ivle.webapp.base.plugins import PublicViewPlugin, ViewPlugin, MediaPlugin
30
30
from ivle.webapp.errors import NotFound, Forbidden
31
 
from ivle.webapp.publisher import INF
 
31
from ivle.webapp.routing import INF
32
32
from ivle.webapp import ApplicationRoot
33
33
 
34
34
# This maps a media namespace to an external dependency directory (in this
94
94
            return os.path.join(plugindir, mediadir, self.path)
95
95
 
96
96
class MediaFileView(BaseView):
97
 
    def authorize(self, req):
98
 
        return True
 
97
    permission = None
99
98
 
100
99
    def render(self, req):
101
100
        # If it begins with ".." or separator, it's illegal. Die.
103
102
           self.context.path.startswith('/'):
104
103
            raise Forbidden()
105
104
 
106
 
        filename = self.get_filename(req)
 
105
        filename = self.context.filename
107
106
        if filename is None:
108
107
            raise NotFound()
109
108
 
128
127
        req.content_type = type
129
128
        req.sendfile(filename)
130
129
 
131
 
    def get_filename(self, req):
132
 
        return self.context.filename
 
130
    def get_permissions(self, user):
 
131
        return set()
133
132
 
134
133
def root_to_media(root, *segments):
135
134
    if segments[0].startswith('+'):
161
160
class Plugin(ViewPlugin, PublicViewPlugin):
162
161
    forward_routes = [(ApplicationRoot, '+media', root_to_media, INF)]
163
162
    views = [(MediaFile, '+index', MediaFileView)]
164
 
    public_forward_routes = forward_routes
165
 
    public_views = views