Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 927

Show
Ignore:
Timestamp:
01/13/06 09:40:27
Author:
lawouach
Message:

added a content_types option to the static_filter. you can now do:
/path
static_filter.on = True
static_filter.content_types = {'atom': 'application/atom+xml', 'rss': 'application/rss+xml'}
static_filter.dir = '/path/to/'

http://host/feed.atom will return application/atom+xml
http://host/feed.rss will return application/rss+xml

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/filters/staticfilter.py

    r922 r927  
    6666             
    6767        try: 
    68             cptools.serveFile(filename) 
     68            # you can set the content types for a complete directory per extension 
     69            content_types = config.get('static_filter.content_types', None) 
     70            content_type = None 
     71            if content_types: 
     72                root, ext = os.path.splitext(filename) 
     73                content_type = content_types.get(ext[1:], None) 
     74            cptools.serveFile(filename, contentType=content_type) 
    6975            request.execute_main = False 
    7076        except cherrypy.NotFound: 
     
    8187                    except cherrypy.NotFound: 
    8288                        pass 
    83  

Hosted by WebFaction

Log in as guest/cpguest to create tickets