Changeset 5922


Ignore:
Timestamp:
11 Apr 2011, 20:41:03 (13 years ago)
Author:
uli
Message:

Set dynamic content type for streamed files instead of hardcoding
JPEG.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/image/browser/views.py

    r5693 r5922  
    2222"""Views for images and the like.
    2323"""
     24import mimetypes
    2425import grok
    2526from hurry.file.interfaces import IHurryFile
     
    3132
    3233    def render(self):
    33         self.response.setHeader('Content-Type', 'image/jpeg')
    34         print dir(self.context)
    35         print self.context.headers
     34        """Output the data of context.
     35
     36        Beside this we set the output MIME type according to the
     37        context's filename.
     38        """
     39        content_type = mimetypes.guess_type(self.context.filename.lower())
     40        if content_type is not None:
     41            self.response.setHeader('Content-Type', content_type)
    3642        return self.context.data
Note: See TracChangeset for help on using the changeset viewer.