From c5b17ba4e116aa6fafa189ae1e2b8351aeaff6ab Mon Sep 17 00:00:00 2001 From: Yaser Amiri Date: Tue, 6 Feb 2018 23:55:47 +0330 Subject: [PATCH] Add flask.g section to show g object content. --- flask_debugtoolbar/__init__.py | 1 + flask_debugtoolbar/panels/g.py | 29 ++++++++++++++++++++++ flask_debugtoolbar/templates/panels/g.html | 16 ++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 flask_debugtoolbar/panels/g.py create mode 100644 flask_debugtoolbar/templates/panels/g.html diff --git a/flask_debugtoolbar/__init__.py b/flask_debugtoolbar/__init__.py index 80c896d..14f97e6 100644 --- a/flask_debugtoolbar/__init__.py +++ b/flask_debugtoolbar/__init__.py @@ -99,6 +99,7 @@ def _default_config(self, app): 'flask_debugtoolbar.panels.logger.LoggingPanel', 'flask_debugtoolbar.panels.route_list.RouteListDebugPanel', 'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel', + 'flask_debugtoolbar.panels.g.GDebugPanel', ), } diff --git a/flask_debugtoolbar/panels/g.py b/flask_debugtoolbar/panels/g.py new file mode 100644 index 0000000..3f86d44 --- /dev/null +++ b/flask_debugtoolbar/panels/g.py @@ -0,0 +1,29 @@ +from flask import g +from flask_debugtoolbar.panels import DebugPanel + +_ = lambda x: x + + +class GDebugPanel(DebugPanel): + """ + A panel to display flask.g content. + """ + name = 'g' + has_content = True + + def nav_title(self): + return _('flask.g') + + def title(self): + return _('flask.g content') + + def url(self): + return '' + + def content(self): + context = self.context.copy() + context.update({ + 'g_content': g.__dict__ + }) + return self.render('panels/g.html', context) + diff --git a/flask_debugtoolbar/templates/panels/g.html b/flask_debugtoolbar/templates/panels/g.html new file mode 100644 index 0000000..f133991 --- /dev/null +++ b/flask_debugtoolbar/templates/panels/g.html @@ -0,0 +1,16 @@ + + + + + + + + + {% for key, value in g_content|dictsort %} + + + + + {% endfor %} + +
KeyValue
{{ key|escape }}{{ value|escape }}