~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-04-28 05:06:00 UTC
  • Revision ID: grantw@unimelb.edu.au-20090428050600-hogd9d6wo7ksyqy8
ivle.database.get_store() now takes a configuration object.

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