# HG changeset patch # User Ludovic Chabant # Date 1396883578 25200 # Node ID 4209868e0e6ccae1fe06f2581a7f8b14643b6148 # Parent c94a3b37f71036facd435215f280a5f77ef3538b Add ability to use a profiling middleware on the WSGI application. diff -r c94a3b37f710 -r 4209868e0e6c wikked/web.py --- a/wikked/web.py Mon Apr 07 08:12:28 2014 -0700 +++ b/wikked/web.py Mon Apr 07 08:12:58 2014 -0700 @@ -24,6 +24,8 @@ app.config.setdefault('WIKI_AUTO_RELOAD', False) app.config.setdefault('WIKI_ASYNC_UPDATE', False) app.config.setdefault('BROKER_URL', 'sqla+sqlite:///%(root)s/.wiki/broker.db') +app.config.setdefault('PROFILE', False) +app.config.setdefault('PROFILE_DIR', None) # Find the wiki root, and further configure the app if there's a @@ -48,6 +50,13 @@ }) +# Profiling +if app.config['PROFILE']: + profile_dir = app.config['PROFILE_DIR'] + from werkzeug.contrib.profiler import ProfilerMiddleware + app.wsgi_app = ProfilerMiddleware(app.wsgi_app, profile_dir=profile_dir) + + # Customize logging. if app.config['DEBUG']: l = logging.getLogger('wikked')