changeset 260:4209868e0e6c

Add ability to use a profiling middleware on the WSGI application.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 07 Apr 2014 08:12:58 -0700
parents c94a3b37f710
children 6f51757e7da1
files wikked/web.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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')