changeset 6571:908e186abd8d

backend: add TurboGears2 DebugBar support DebugBar is a toolbar overlayed over the Kallithea web interface, allowing you to see: * timing information of the current request, including profiling information * request data, including GET data, POST data, cookies, headers and environment variables * a list of executed database queries, including timing and result values Enable it automatically when in debug mode and all requirements are met. Add documentation.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Sat, 28 Jan 2017 20:46:00 +0100
parents 26fb17b4f925
children be56b2426b90
files docs/contributing.rst kallithea/config/app_cfg.py
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/docs/contributing.rst	Tue Dec 13 19:37:24 2016 +0100
+++ b/docs/contributing.rst	Sat Jan 28 20:46:00 2017 +0100
@@ -204,6 +204,25 @@
 a freshly created model object (before flushing, the ID attribute will
 be ``None``).
 
+TurboGears2 DebugBar
+^^^^^^^^^^^^^^^^^^^^
+
+It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed
+over the Kallithea web interface, allowing you to see:
+
+* timing information of the current request, including profiling information
+* request data, including GET data, POST data, cookies, headers and environment
+  variables
+* a list of executed database queries, including timing and result values
+
+DebugBar is only activated when ``debug = true`` is set in the configuration
+file. This is important, because the DebugBar toolbar will be visible for all
+users, and allow them to see information they should not be allowed to see. Like
+is anyway the case for ``debug = true``, do not use this in production!
+
+To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via
+``pip``) and restart Kallithea (in debug mode).
+
 
 "Roadmap"
 ---------
@@ -225,3 +244,4 @@
 .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
 .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/
 .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home
+.. _DebugBar: https://github.com/TurboGears/tgext.debugbar
--- a/kallithea/config/app_cfg.py	Tue Dec 13 19:37:24 2016 +0100
+++ b/kallithea/config/app_cfg.py	Sat Jan 28 20:46:00 2017 +0100
@@ -96,6 +96,21 @@
 # TODO still needed as long as we use pylonslib
 sys.modules['pylons'] = tg
 
+# DebugBar, a debug toolbar for TurboGears2.
+# (https://github.com/TurboGears/tgext.debugbar)
+# To enable it, install 'tgext.debugbar' and 'kajiki', and run Kallithea with
+# 'debug = true' (not in production!)
+# See the Kallithea documentation for more information.
+try:
+    from tgext.debugbar import enable_debugbar
+    import kajiki # only to check its existence
+except ImportError:
+    pass
+else:
+    base_config['renderers'].append('kajiki')
+    enable_debugbar(base_config)
+
+
 def setup_configuration(app):
     config = app.config