view decoupage/factory.py @ 95:c0f6a87d4dd8

paster still throws a fit about this but might as well enable it to do so
author Jeff Hammel <k0scist@gmail.com>
date Sun, 21 Aug 2016 19:39:18 -0700
parents 9c570aed2246
children 450aff4c97e3
line wrap: on
line source

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)