Example #1
0
def make_app(root, static_root=None, debug=False, errorcfg={}, wrap_app=None, **kw):
    '''
    
    '''

    app = Pecan(root, **kw)
    if wrap_app:
        app = wrap_app(app)
    app = RecursiveMiddleware(app)
    if debug:
        app = EvalException(app, templating_formatters=error_formatters, **errorcfg)
    else:
        app = ErrorMiddleware(app, **errorcfg)
    app = make_errordocument(app, conf, **conf.app.errors)
    if static_root:
        app = Cascade([StaticURLParser(static_root), app])
    return app
Example #2
0
def make_app(root, static_root=None, debug=False, errorcfg={}, wrap_app=None, logging=False, **kw):
    '''
    
    '''
    if hasattr(conf, 'requestviewer'):
        existing_hooks = kw.get('hooks', [])
        existing_hooks.append(RequestViewerHook(conf.requestviewer))
        kw['hooks'] = existing_hooks

    app = Pecan(root, **kw)
    if wrap_app:
        app = wrap_app(app)
    app = RecursiveMiddleware(app)
    if debug:
        app = EvalException(app, templating_formatters=error_formatters, **errorcfg)
    else:
        app = ErrorMiddleware(app, **errorcfg)
    app = make_errordocument(app, conf, **conf.app.errors)
    if static_root:
        app = Cascade([StaticURLParser(static_root), app])
    if isinstance(logging, dict) or logging == True:
        app = TransLogger(app, **(isinstance(logging, dict) and logging or {}))
    return app