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

« back to all changes in this revision

Viewing changes to ivle/webapp/media.py

  • Committer: Matt Giuca
  • Date: 2009-05-19 02:54:08 UTC
  • mfrom: (1258 trunk)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090519025408-19c7cjl7w6ot6frm
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import mimetypes
26
26
import email.utils
27
27
 
28
 
import ivle.conf
29
 
from ivle.config import Config
30
28
from ivle.webapp.base.views import BaseView
31
29
from ivle.webapp.base.plugins import PublicViewPlugin, ViewPlugin, MediaPlugin
32
30
from ivle.webapp.errors import NotFound, Forbidden
43
41
    if not isinstance(plugin, basestring):
44
42
        plugin = req.config.reverse_plugins[plugin]
45
43
 
46
 
    config = Config()
47
 
 
48
 
    media_path = os.path.join('+media', '+' + config['media']['version']) if \
49
 
                              config['media']['version'] else '+media'
50
 
 
51
 
    return os.path.join(ivle.conf.root_dir, media_path, plugin, path)
 
44
    media_path = os.path.join('+media', '+' + req.config['media']['version']) \
 
45
                    if req.config['media']['version'] else '+media'
 
46
 
 
47
    return req.make_path(os.path.join(media_path, plugin, path))
52
48
 
53
49
class BaseMediaFileView(BaseView):
54
50
    '''A view for media files.
130
126
        self.version = version
131
127
 
132
128
    def _make_filename(self, req):
133
 
        if self.version != Config()['media']['version']:
 
129
        if self.version != req.config['media']['version']:
134
130
            raise NotFound()
135
131
 
136
132
        # Don't expire for a year.
165
161
            raise NotFound()
166
162
 
167
163
        # Grab the admin-configured path for this particular external dep.
168
 
        config = Config()
169
 
        externdir = config['media']['externals'][extern[0]]
 
164
        externdir = req.config['media']['externals'][extern[0]]
170
165
 
171
166
        assert isinstance(externdir, basestring)
172
167
 
188
183
        self.version = version
189
184
 
190
185
    def _make_filename(self, req):
191
 
        if self.version != Config()['media']['version']:
 
186
        if self.version != req.config['media']['version']:
192
187
            raise NotFound()
193
188
 
194
189
        # Don't expire for a year.