mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-06 05:30:12 -06:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45d3588bb6 | ||
|
|
15e8d77a49 | ||
|
|
4d84f262ae | ||
|
|
db64ce632c | ||
|
|
956d7501ec | ||
|
|
a758a9df7a | ||
|
|
5eea25882c | ||
|
|
e954cd9fae | ||
|
|
03d79be02c | ||
|
|
7f17d2ce57 | ||
|
|
30fba11f36 | ||
|
|
d474a6a689 | ||
|
|
83d398d9d5 | ||
|
|
3929742d9c | ||
|
|
70abd78e55 | ||
|
|
dbea74b626 | ||
|
|
c6102aeb14 | ||
|
|
10c9c1ae5d | ||
|
|
9e600c6e13 | ||
|
|
9b8a8afa97 | ||
|
|
39ac97a7e0 | ||
|
|
a5cb5a709f | ||
|
|
02064c76ed | ||
|
|
d713732807 | ||
|
|
b92391d177 | ||
|
|
4964ae261f | ||
|
|
ad847299c4 | ||
|
|
7ce099c3d0 | ||
|
|
9c7db48362 | ||
|
|
88f15cba35 | ||
|
|
d852042ccb | ||
|
|
5bd2e8a423 | ||
|
|
c27256c00a | ||
|
|
010206298e | ||
|
|
678ec31229 | ||
|
|
23d52703fd | ||
|
|
45b70c952f | ||
|
|
9f2c353e86 | ||
|
|
cfe142b285 | ||
|
|
19a25fd895 | ||
|
|
8dcb97c05a | ||
|
|
b49af327cf | ||
|
|
38ab3a49c1 | ||
|
|
9f901e34ae | ||
|
|
f050a6b0de | ||
|
|
e33f3e1c85 | ||
|
|
02ff95acde | ||
|
|
2436239964 | ||
|
|
18a0030354 |
@@ -1,9 +1,9 @@
|
|||||||
|
sudo: false
|
||||||
language: python
|
language: python
|
||||||
python: "2.7"
|
python: "3.8"
|
||||||
env:
|
env:
|
||||||
- TOXENV=py26
|
|
||||||
- TOXENV=py27
|
- TOXENV=py27
|
||||||
- TOXENV=py33
|
- TOXENV=py38
|
||||||
install:
|
install:
|
||||||
- pip install tox --use-mirrors
|
- pip install tox
|
||||||
script: tox
|
script: tox
|
||||||
|
|||||||
78
CHANGES.rst
78
CHANGES.rst
@@ -1,6 +1,84 @@
|
|||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
0.14.0 (Unreleased)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
|
||||||
|
- ??
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- ??
|
||||||
|
|
||||||
|
0.13.1 (2022-03-29)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Use a consistent version naming convention, 0.13 should have been 0.13.0 but it was yanked and you can't re-push yanked packages with the same version
|
||||||
|
|
||||||
|
0.13 (2022-03-29)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Correct `setup.cfg` to include package files by @nickjj in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/172
|
||||||
|
|
||||||
|
0.12.1 (2022-03-28)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Correct changelog and docs URLs on PyPI
|
||||||
|
|
||||||
|
|
||||||
|
0.12.0 (2022-03-28)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
|
||||||
|
- Add flask.g section to show g object content. by @Yaser-Amiri in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/118
|
||||||
|
- Support gzip response by @zaw007 in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/154
|
||||||
|
- Update PyPI metadata files: add `setup.cfg` etc by @jeffwidman in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/164
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Remove deprecated Jinja with_ extension for Jinja 3.0 (related to Flask 2.0) by @nickjj in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/157
|
||||||
|
- Fix SQLAlchemy SELECT/EXPLAIN to use url_for to respect app prefixes.… by @mattaw in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/143
|
||||||
|
- Setup DB properly by @jeffwidman in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/148
|
||||||
|
- prefixed css classes, fixes #152 by @jnnkB in https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/153
|
||||||
|
|
||||||
|
|
||||||
|
0.11.0 (2020-02-18)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
|
||||||
|
- Switch to Flask's native CLI, dropping flask_script in the process (b92391d, thanks @jeffwidman)
|
||||||
|
- Do not show DebugToolbar routes in the route map (#86, thanks @floqqi)
|
||||||
|
- Document Pygments for SQL highlighting (#127, thanks @pgiraud)
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Remove deprecated flask.json_available (#119, thanks @davidism)
|
||||||
|
- Remove deprecated request.is_xhr (7ce099c, thanks @jeffwidman)
|
||||||
|
- Explicitly disable `SQLALCHEMY_TRACK_MODIFICATIONS` (9c7db48, thanks @jeffwidman)
|
||||||
|
- Fix typo (#142, thanks @timgates42)
|
||||||
|
|
||||||
|
|
||||||
|
0.10.1 (2017-02-12)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
- Add support for Python wheels
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Switch imports from deprecated flask.ext.* to flask_* syntax (#94, thanks
|
||||||
|
Michael Lenzen & #97 thanks Iuri de Silvio)
|
||||||
|
|
||||||
0.10.0 (2015-04-17)
|
0.10.0 (2015-04-17)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
recursive-include flask_debugtoolbar/templates *.html
|
include LICENSE
|
||||||
recursive-include flask_debugtoolbar/static *
|
recursive-include src/flask_debugtoolbar/templates *.html
|
||||||
|
recursive-include src/flask_debugtoolbar/static *
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ Flask Debug-toolbar
|
|||||||
This is a port of the excellent `django-debug-toolbar <https://github.com/django-debug-toolbar/django-debug-toolbar>`_
|
This is a port of the excellent `django-debug-toolbar <https://github.com/django-debug-toolbar/django-debug-toolbar>`_
|
||||||
for Flask applications.
|
for Flask applications.
|
||||||
|
|
||||||
.. image:: https://travis-ci.org/mgood/flask-debugtoolbar.png?branch=master
|
.. image:: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar.png?branch=master
|
||||||
:target: https://travis-ci.org/mgood/flask-debugtoolbar
|
:target: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
@@ -40,4 +40,4 @@ In production, setting ``app.debug = False`` will disable the toolbar.
|
|||||||
|
|
||||||
See the `documentation`_ for more information.
|
See the `documentation`_ for more information.
|
||||||
|
|
||||||
.. _documentation: http://flask-debugtoolbar.readthedocs.org
|
.. _documentation: https://flask-debugtoolbar.readthedocs.io/
|
||||||
|
|||||||
21
docs/conf.py
21
docs/conf.py
@@ -11,7 +11,16 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import sys, os
|
import datetime
|
||||||
|
import os
|
||||||
|
import pkg_resources
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import flask_debugtoolbar
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_DATE = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
@@ -44,16 +53,16 @@ master_doc = 'index'
|
|||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'Flask-DebugToolbar'
|
project = u'Flask-DebugToolbar'
|
||||||
copyright = u'2012-2015'
|
copyright = u'2012-{0}'.format(BUILD_DATE.year)
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
|
||||||
version = '0.10'
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.10.0'
|
release = flask_debugtoolbar.__version__
|
||||||
|
# The short X.Y version.
|
||||||
|
version = '.'.join(release.split('.')[:2])
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
@@ -90,7 +99,7 @@ pygments_style = 'sphinx'
|
|||||||
#modindex_common_prefix = []
|
#modindex_common_prefix = []
|
||||||
|
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {
|
||||||
'flasksqlalchemy': ('http://flask-sqlalchemy.pocoo.org/2.0/', None)
|
'flasksqlalchemy': ('http://flask-sqlalchemy.pocoo.org/latest/', None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Time
|
|||||||
|
|
||||||
flask_debugtoolbar.panels.timer.TimerDebugPanel
|
flask_debugtoolbar.panels.timer.TimerDebugPanel
|
||||||
|
|
||||||
Shows the time taken to process the current request. The exapanded view includes the breakdown of CPU time, by user and system, wall clock time, and context switches.
|
Shows the time taken to process the current request. The expanded view includes the breakdown of CPU time, by user and system, wall clock time, and context switches.
|
||||||
|
|
||||||
.. image:: _static/screenshot-time-panel.png
|
.. image:: _static/screenshot-time-panel.png
|
||||||
|
|
||||||
@@ -70,12 +70,16 @@ Shows SQL queries run during the current request.
|
|||||||
:ref:`flasksqlalchemy:quickstart` section to configure it.
|
:ref:`flasksqlalchemy:quickstart` section to configure it.
|
||||||
|
|
||||||
For additional details on query recording see the
|
For additional details on query recording see the
|
||||||
:py:func:`~flask.ext.sqlalchemy.get_debug_queries` documentation.
|
:py:func:`~flask_sqlalchemy.get_debug_queries` documentation.
|
||||||
|
|
||||||
|
.. note:: SQL syntax highlighting requires `Pygments`_ to be installed.
|
||||||
|
|
||||||
.. image:: _static/screenshot-sqlalchemy-panel.png
|
.. image:: _static/screenshot-sqlalchemy-panel.png
|
||||||
|
|
||||||
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/
|
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/
|
||||||
|
|
||||||
|
.. _Pygments: http://pygments.org/
|
||||||
|
|
||||||
|
|
||||||
Logging
|
Logging
|
||||||
-------
|
-------
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import sys
|
# Run using: `FLASK_ENV=development flask run`
|
||||||
sys.path.insert(0, '.')
|
|
||||||
|
|
||||||
from flask import Flask, render_template, redirect, url_for
|
from flask import Flask, render_template, redirect, url_for
|
||||||
from flask.ext.script import Manager
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask.ext.sqlalchemy import SQLAlchemy
|
|
||||||
from flask_debugtoolbar import DebugToolbarExtension
|
from flask_debugtoolbar import DebugToolbarExtension
|
||||||
|
|
||||||
|
|
||||||
@@ -16,7 +14,10 @@ app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
|
|||||||
#)
|
#)
|
||||||
#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' )
|
#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' )
|
||||||
app.config['SECRET_KEY'] = 'asd'
|
app.config['SECRET_KEY'] = 'asd'
|
||||||
app.config['DEBUG'] = True
|
|
||||||
|
# TODO: This can be removed once flask_sqlalchemy 3.0 ships
|
||||||
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
|
||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
|
|
||||||
@@ -28,6 +29,11 @@ class ExampleModel(db.Model):
|
|||||||
value = db.Column(db.String(100), primary_key=True)
|
value = db.Column(db.String(100), primary_key=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_first_request
|
||||||
|
def setup():
|
||||||
|
db.create_all()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
app.logger.info("Hello there")
|
app.logger.info("Hello there")
|
||||||
@@ -37,13 +43,6 @@ def index():
|
|||||||
|
|
||||||
@app.route('/redirect')
|
@app.route('/redirect')
|
||||||
def redirect_example():
|
def redirect_example():
|
||||||
|
|
||||||
response = redirect(url_for('index'))
|
response = redirect(url_for('index'))
|
||||||
response.set_cookie('test_cookie', '1')
|
response.set_cookie('test_cookie', '1')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
db.create_all()
|
|
||||||
|
|
||||||
manager = Manager(app)
|
|
||||||
manager.run()
|
|
||||||
6
pyproject.toml
Normal file
6
pyproject.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = [
|
||||||
|
"setuptools>=42",
|
||||||
|
"wheel"
|
||||||
|
]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
36
setup.cfg
Normal file
36
setup.cfg
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[metadata]
|
||||||
|
name = Flask-DebugToolbar
|
||||||
|
version = 0.13.1
|
||||||
|
author = Michael van Tellingen
|
||||||
|
author_email = michaelvantellingen@gmail.com
|
||||||
|
maintainer = Matt Good
|
||||||
|
maintainer_email = matt@matt-good.net
|
||||||
|
description = A toolbar overlay for debugging Flask applications.
|
||||||
|
long_description = file: README.rst
|
||||||
|
long_description_content_type = text/x-rst
|
||||||
|
keywords = flask, debug, toolbar
|
||||||
|
url = https://github.com/flask-debugtoolbar/flask-debugtoolbar
|
||||||
|
project_urls =
|
||||||
|
Changelog = https://github.com/flask-debugtoolbar/flask-debugtoolbar/blob/master/CHANGES.rst
|
||||||
|
Documentation = https://flask-debugtoolbar.readthedocs.io/
|
||||||
|
classifiers =
|
||||||
|
Development Status :: 4 - Beta
|
||||||
|
Environment :: Web Environment
|
||||||
|
Framework :: Flask
|
||||||
|
Intended Audience :: Developers
|
||||||
|
License :: OSI Approved :: BSD License
|
||||||
|
Operating System :: OS Independent
|
||||||
|
Programming Language :: Python
|
||||||
|
Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||||
|
Topic :: Software Development :: Libraries :: Python Modules
|
||||||
|
|
||||||
|
[options]
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
|
||||||
|
packages = find:
|
||||||
|
include_package_data = True
|
||||||
|
python_requires = >=2.7
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
42
setup.py
42
setup.py
@@ -1,48 +1,12 @@
|
|||||||
import os
|
from setuptools import setup
|
||||||
from setuptools import setup, find_packages
|
|
||||||
|
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
|
|
||||||
try:
|
|
||||||
README = open(os.path.join(here, 'README.rst')).read()
|
|
||||||
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
|
|
||||||
except:
|
|
||||||
README = ''
|
|
||||||
CHANGES = ''
|
|
||||||
|
|
||||||
|
|
||||||
|
# Metadata goes in setup.cfg. These are here for GitHub's dependency graph.
|
||||||
setup(
|
setup(
|
||||||
name='Flask-DebugToolbar',
|
name="Flask-DebugToolbar",
|
||||||
version='0.10.0',
|
|
||||||
url='http://flask-debugtoolbar.rtfd.org/',
|
|
||||||
license='BSD',
|
|
||||||
author='Michael van Tellingen',
|
|
||||||
author_email='michaelvantellingen@gmail.com',
|
|
||||||
maintainer='Matt Good',
|
|
||||||
maintainer_email='matt@matt-good.net',
|
|
||||||
description='A toolbar overlay for debugging Flask applications.',
|
|
||||||
long_description=README + '\n\n' + CHANGES,
|
|
||||||
zip_safe=False,
|
|
||||||
platforms='any',
|
|
||||||
include_package_data=True,
|
|
||||||
packages=['flask_debugtoolbar',
|
|
||||||
'flask_debugtoolbar.panels'
|
|
||||||
],
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Flask>=0.8',
|
'Flask>=0.8',
|
||||||
'Blinker',
|
'Blinker',
|
||||||
'itsdangerous',
|
'itsdangerous',
|
||||||
'werkzeug',
|
'werkzeug',
|
||||||
],
|
],
|
||||||
classifiers=[
|
|
||||||
'Development Status :: 4 - Beta',
|
|
||||||
'Environment :: Web Environment',
|
|
||||||
'Intended Audience :: Developers',
|
|
||||||
'License :: OSI Approved :: BSD License',
|
|
||||||
'Operating System :: OS Independent',
|
|
||||||
'Programming Language :: Python',
|
|
||||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
import os
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from flask import Blueprint, current_app, request, g, send_from_directory
|
from flask import Blueprint, current_app, request, g, send_from_directory, url_for
|
||||||
from flask.globals import _request_ctx_stack
|
from flask.globals import _request_ctx_stack
|
||||||
|
from jinja2 import __version__ as __jinja_version__
|
||||||
from jinja2 import Environment, PackageLoader
|
from jinja2 import Environment, PackageLoader
|
||||||
from werkzeug.urls import url_quote_plus
|
from werkzeug.urls import url_quote_plus
|
||||||
|
|
||||||
from flask_debugtoolbar.compat import iteritems
|
from flask_debugtoolbar.compat import iteritems
|
||||||
from flask_debugtoolbar.toolbar import DebugToolbar
|
from flask_debugtoolbar.toolbar import DebugToolbar
|
||||||
from flask_debugtoolbar.utils import decode_text
|
from flask_debugtoolbar.utils import decode_text, gzip_compress, gzip_decompress
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python 3.8+
|
||||||
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
__version__ = version("Flask-DebugToolbar")
|
||||||
|
except ImportError:
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
__version__ = pkg_resources.get_distribution("Flask-DebugToolbar").version
|
||||||
|
|
||||||
|
|
||||||
module = Blueprint('debugtoolbar', __name__)
|
module = Blueprint('debugtoolbar', __name__)
|
||||||
@@ -44,15 +55,20 @@ class DebugToolbarExtension(object):
|
|||||||
def __init__(self, app=None):
|
def __init__(self, app=None):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.debug_toolbars = {}
|
self.debug_toolbars = {}
|
||||||
|
jinja_extensions = ['jinja2.ext.i18n']
|
||||||
|
|
||||||
|
if __jinja_version__[0] == '2':
|
||||||
|
jinja_extensions.append('jinja2.ext.with_')
|
||||||
|
|
||||||
# Configure jinja for the internal templates and add url rules
|
# Configure jinja for the internal templates and add url rules
|
||||||
# for static data
|
# for static data
|
||||||
self.jinja_env = Environment(
|
self.jinja_env = Environment(
|
||||||
autoescape=True,
|
autoescape=True,
|
||||||
extensions=['jinja2.ext.i18n', 'jinja2.ext.with_'],
|
extensions=jinja_extensions,
|
||||||
loader=PackageLoader(__name__, 'templates'))
|
loader=PackageLoader(__name__, 'templates'))
|
||||||
self.jinja_env.filters['urlencode'] = url_quote_plus
|
self.jinja_env.filters['urlencode'] = url_quote_plus
|
||||||
self.jinja_env.filters['printable'] = _printable
|
self.jinja_env.filters['printable'] = _printable
|
||||||
|
self.jinja_env.globals['url_for'] = url_for
|
||||||
|
|
||||||
if app is not None:
|
if app is not None:
|
||||||
self.init_app(app)
|
self.init_app(app)
|
||||||
@@ -99,6 +115,7 @@ class DebugToolbarExtension(object):
|
|||||||
'flask_debugtoolbar.panels.logger.LoggingPanel',
|
'flask_debugtoolbar.panels.logger.LoggingPanel',
|
||||||
'flask_debugtoolbar.panels.route_list.RouteListDebugPanel',
|
'flask_debugtoolbar.panels.route_list.RouteListDebugPanel',
|
||||||
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
|
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
|
||||||
|
'flask_debugtoolbar.panels.g.GDebugPanel',
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +195,7 @@ class DebugToolbarExtension(object):
|
|||||||
# Intercept http redirect codes and display an html page with a
|
# Intercept http redirect codes and display an html page with a
|
||||||
# link to the target.
|
# link to the target.
|
||||||
if current_app.config['DEBUG_TB_INTERCEPT_REDIRECTS']:
|
if current_app.config['DEBUG_TB_INTERCEPT_REDIRECTS']:
|
||||||
if (response.status_code in self._redirect_codes and
|
if response.status_code in self._redirect_codes:
|
||||||
not real_request.is_xhr):
|
|
||||||
redirect_to = response.location
|
redirect_to = response.location
|
||||||
redirect_code = response.status_code
|
redirect_code = response.status_code
|
||||||
if redirect_to:
|
if redirect_to:
|
||||||
@@ -199,7 +215,10 @@ class DebugToolbarExtension(object):
|
|||||||
response.headers['content-type'].startswith('text/html')):
|
response.headers['content-type'].startswith('text/html')):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
response_html = response.data.decode(response.charset)
|
if 'gzip' in response.headers.get('Content-Encoding', ''):
|
||||||
|
response_html = gzip_decompress(response.data).decode(response.charset)
|
||||||
|
else:
|
||||||
|
response_html = response.data.decode(response.charset)
|
||||||
|
|
||||||
no_case = response_html.lower()
|
no_case = response_html.lower()
|
||||||
body_end = no_case.rfind('</body>')
|
body_end = no_case.rfind('</body>')
|
||||||
@@ -224,6 +243,8 @@ class DebugToolbarExtension(object):
|
|||||||
|
|
||||||
content = ''.join((before, toolbar_html, after))
|
content = ''.join((before, toolbar_html, after))
|
||||||
content = content.encode(response.charset)
|
content = content.encode(response.charset)
|
||||||
|
if 'gzip' in response.headers.get('Content-Encoding', ''):
|
||||||
|
content = gzip_compress(content)
|
||||||
response.response = [content]
|
response.response = [content]
|
||||||
response.content_length = len(content)
|
response.content_length = len(content)
|
||||||
|
|
||||||
29
src/flask_debugtoolbar/panels/g.py
Normal file
29
src/flask_debugtoolbar/panels/g.py
Normal file
@@ -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)
|
||||||
|
|
||||||
@@ -26,7 +26,11 @@ class RouteListDebugPanel(DebugPanel):
|
|||||||
return '%s %s' % (count, 'route' if count == 1 else 'routes')
|
return '%s %s' % (count, 'route' if count == 1 else 'routes')
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
self.routes = list(current_app.url_map.iter_rules())
|
self.routes = [
|
||||||
|
rule
|
||||||
|
for rule in current_app.url_map.iter_rules()
|
||||||
|
if not rule.rule.startswith('/_debug_toolbar')
|
||||||
|
]
|
||||||
|
|
||||||
def content(self):
|
def content(self):
|
||||||
return self.render('panels/route_list.html', {
|
return self.render('panels/route_list.html', {
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
try:
|
try:
|
||||||
from flask.ext.sqlalchemy import get_debug_queries, SQLAlchemy
|
from flask_sqlalchemy import get_debug_queries, SQLAlchemy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sqlalchemy_available = False
|
sqlalchemy_available = False
|
||||||
get_debug_queries = SQLAlchemy = None
|
get_debug_queries = SQLAlchemy = None
|
||||||
else:
|
else:
|
||||||
sqlalchemy_available = True
|
sqlalchemy_available = True
|
||||||
|
|
||||||
from flask import request, current_app, abort, json_available, g
|
from flask import request, current_app, abort, g
|
||||||
from flask_debugtoolbar import module
|
from flask_debugtoolbar import module
|
||||||
from flask_debugtoolbar.panels import DebugPanel
|
from flask_debugtoolbar.panels import DebugPanel
|
||||||
from flask_debugtoolbar.utils import format_fname, format_sql
|
from flask_debugtoolbar.utils import format_fname, format_sql
|
||||||
@@ -59,8 +59,7 @@ def recording_enabled():
|
|||||||
|
|
||||||
|
|
||||||
def is_available():
|
def is_available():
|
||||||
return (json_available and sqlalchemy_available
|
return sqlalchemy_available and extension_used() and recording_enabled()
|
||||||
and extension_used() and recording_enabled())
|
|
||||||
|
|
||||||
|
|
||||||
def get_queries():
|
def get_queries():
|
||||||
@@ -108,7 +107,6 @@ class SQLAlchemyDebugPanel(DebugPanel):
|
|||||||
|
|
||||||
if not queries and not is_available():
|
if not queries and not is_available():
|
||||||
return self.render('panels/sqlalchemy_error.html', {
|
return self.render('panels/sqlalchemy_error.html', {
|
||||||
'json_available': json_available,
|
|
||||||
'sqlalchemy_available': sqlalchemy_available,
|
'sqlalchemy_available': sqlalchemy_available,
|
||||||
'extension_used': extension_used(),
|
'extension_used': extension_used(),
|
||||||
'recording_enabled': recording_enabled(),
|
'recording_enabled': recording_enabled(),
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user