Mercurial > hg > decoupage
diff decoupage/factory.py @ 63:9c570aed2246
move app_conf parsing logic to factory.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 14 Dec 2010 22:03:50 -0800 |
parents | 6a802c87f070 |
children | 450aff4c97e3 |
line wrap: on
line diff
--- a/decoupage/factory.py Mon Nov 29 17:53:20 2010 -0800 +++ b/decoupage/factory.py Tue Dec 14 22:03:50 2010 -0800 @@ -1,8 +1,16 @@ from web import Decoupage from paste.httpexceptions import HTTPExceptionHandler +def namespace_conf(keystr, app_conf): + keystr += '.' + return dict([(key.split(keystr, 1)[-1], value) + for key, value in app_conf.items() + if key.startswith(keystr) ]) + + def factory(global_conf, **app_conf): """create a webob view and wrap it in middleware""" + app_conf = namespace_conf('decoupage', app_conf) app = Decoupage(**app_conf) return HTTPExceptionHandler(app)