Using the latest version of the route, you can use the Magic path_info 'function and follow the documentation from here to write your controller so it calls paster.DirectoryApp.
In my project, I wanted to serve any file in a public directory, including sub-folders, and ended this up as a controller to override the content_type:
import logging from paste.fileapp import FileApp from paste.urlparser import StaticURLParser from pylons import config from os.path import basename class ForceDownloadController(StaticURLParser): def __init__(self, directory=None, root_directory=None, cache_max_age=None): if not directory: directory = config['pylons.paths']['static_files'] StaticURLParser.__init__(self, directory, root_directory, cache_max_age) def make_app(self, filename): headers = [('Content-Disposition', 'filename=%s' % (basename(filename)))] return FileApp(filename, headers, content_type='application/octetstream')
Antonin ENFRUN
source share