Mercurial > hg > MakeItSo
changeset 47:e8d5782f6678
remove paste factory
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 05 Jan 2011 18:18:26 -0800 |
parents | a82aa8b2ad93 |
children | 1b9573832f33 |
files | makeitso/factory.py |
diffstat | 1 files changed, 0 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/factory.py Wed Jan 05 18:09:50 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -import os - -from dispatcher import Dispatcher -from paste.httpexceptions import HTTPExceptionHandler -from paste.urlparser import StaticURLParser -from pkg_resources import resource_filename - -class PassthroughFileserver(object): - """serve files if they exist""" - - def __init__(self, app, directory): - self.app = app - self.directory = directory - self.fileserver = StaticURLParser(self.directory) - - def __call__(self, environ, start_response): - path = environ['PATH_INFO'].strip('/') - if path and os.path.exists(os.path.join(self.directory, path)): - return self.fileserver(environ, start_response) - return self.app(environ, start_response) - -def factory(global_conf, **app_conf): - """create a webob view and wrap it in middleware""" - - keystr = 'MakeItSo/.' - args = dict([(key.split(keystr, 1)[-1], value) - for key, value in app_conf.items() - if key.startswith(keystr) ]) - app = Dispatcher(**args) - return HTTPExceptionHandler(PassthroughFileserver(app, resource_filename(__name__, 'static'))) -