Switch to unified view

a/Allura/allura/model/filesystem.py b/Allura/allura/model/filesystem.py
...
...
21
21
22
import pylons
22
import pylons
23
import PIL
23
import PIL
24
from gridfs import GridFS
24
from gridfs import GridFS
25
from tg import config
25
from tg import config
26
from paste.deploy.converters import asint
27
26
28
from ming import schema
27
from ming import schema
29
from ming.orm import session, FieldProperty
28
from ming.orm import session, FieldProperty
30
from ming.orm.declarative import MappedClass
29
from ming.orm.declarative import MappedClass
31
30
...
...
107
        self.file_id = fp._id
106
        self.file_id = fp._id
108
        return fp
107
        return fp
109
108
110
    def serve(self, embed=True):
109
    def serve(self, embed=True):
111
        '''Sets the response headers and serves as a wsgi iter'''
110
        '''Sets the response headers and serves as a wsgi iter'''
112
        fp = self.rfile()
111
        gridfs_file = self.rfile()
113
        pylons.response.headers['Content-Type'] = ''
112
        return utils.serve_file(gridfs_file, self.filename, self.content_type,
114
        pylons.response.content_type = self.content_type.encode('utf-8')
113
                                last_modified=self._id.generation_time,
115
        pylons.response.cache_expires = asint(config.get('files_expires_header_secs', 60 * 60))
114
                                size=gridfs_file.length,
116
        pylons.response.last_modified = self._id.generation_time
115
                                embed=embed)
117
        if 'Pragma' in pylons.response.headers:
118
            del pylons.response.headers['Pragma']
119
        if 'Cache-Control' in pylons.response.headers:
120
            del pylons.response.headers['Cache-Control']
121
        if not embed:
122
            pylons.response.headers.add(
123
                'Content-Disposition',
124
                'attachment;filename="%s"' % self.filename.encode('utf-8'))
125
        return iter(fp)
126
116
127
    @classmethod
117
    @classmethod
128
    def save_thumbnail(cls, filename, image,
118
    def save_thumbnail(cls, filename, image,
129
                   content_type,
119
                   content_type,
130
                   thumbnail_size=None,
120
                   thumbnail_size=None,