49 Commits

Author SHA1 Message Date
Nick Janetakis
45d3588bb6 Release 0.13.1 2022-03-29 18:39:20 -04:00
Nick Janetakis
15e8d77a49 Fix changelog formatting for 0.12.X 2022-03-29 18:10:40 -04:00
Nick Janetakis
4d84f262ae Merge pull request #172 from flask-debugtoolbar/fix-setupcfg
Move library into src/ directory
2022-03-29 18:08:01 -04:00
Nick Janetakis
db64ce632c Move library into src/ directory
After building this locally I noticed all of the expected files were in
the wheel where as before this patch it was missing a lot of files.

This idea of using a src/ directory is mentioned in the official Python
documentation for packaging files at:

https://packaging.python.org/en/latest/tutorials/packaging-projects/

It's also used in Flask and other large Python projects.
2022-03-29 08:18:21 -04:00
Jeff Widman
956d7501ec Bump version for development 2022-03-28 01:19:17 -07:00
Jeff Widman
a758a9df7a Release 0.12.1 2022-03-28 01:16:17 -07:00
Jeff Widman
5eea25882c Fix changelog / docs link
I fat-fingered this in
https://github.com/flask-debugtoolbar/flask-debugtoolbar/pull/164 so
correcting it.
2022-03-28 01:14:12 -07:00
Jeff Widman
e954cd9fae Bump version for development 2022-03-27 23:48:24 -07:00
Jeff Widman
03d79be02c Release 0.12.0 2022-03-27 23:48:08 -07:00
Jeff Widman
7f17d2ce57 Update PyPI metadata files: add setup.cfg etc (#164)
Update to the newer PyPI / python packaging metadata file structure.

A lot of this was cribbed from how [`Flask`](https://github.com/pallets/flask) itself
exposes its metadata.
2022-03-26 21:51:54 -07:00
Nick Janetakis
30fba11f36 Remove with_ extension for Jinja 3.0 (#157)
Jinja 3.0 throws a deprecation warning that this will be removed in 3.1
because it's built into Jinja now without needing an extension.

However since folks might want to use Jinja 2 for a while this supports
both versions by only using the extension with Jinja 2.
2022-03-25 21:26:26 -07:00
jnnkB
d474a6a689 prefixed css classes, fixes #152 (#153) 2020-08-14 11:39:15 -07:00
zaw007
83d398d9d5 Support gzip response (#154)
* add gzip compress and decompress

* support gzip response
2020-08-14 11:37:37 -07:00
Jeff Widman
3929742d9c Cleanup version handling slightly (#149)
Some improvements I saw over on
https://github.com/FactoryBoy/factory_boy/pull/676/files that looked
useful here as well.
2020-03-09 13:10:02 -07:00
Jeff Widman
70abd78e55 Setup DB properly
When I switched over to `flask run` entrypoint in b92391d177,
I forgot that the `if name==__main__` code no longer triggers.
So the SQLite in-memory database wasn't getting created for the example
app.

This moves the DB creation to a werkzeug/Flask hook that runs before the
first request to the app, so that the DB table is created when we query
it.

Also updated the test which worked fine previously, but this is more
idiomatic.
2020-03-09 10:01:59 -07:00
Jeff Widman
dbea74b626 Update README.rst 2020-03-09 09:46:05 -07:00
Jeff Widman
c6102aeb14 Change docs to pull version from setup.py 2020-03-02 09:37:37 -08:00
Jeff Widman
10c9c1ae5d Update Flask-SQLAlchemy links 2020-02-22 20:39:21 -08:00
Yaser Amiri
9e600c6e13 Add flask.g section to show g object content. 2020-02-22 09:47:21 -08:00
Matthew Swabey
9b8a8afa97 Fix SQLAlchemy SELECT/EXPLAIN to use url_for to respect app prefixes. Provide url_for to all toolbar templates 2020-02-22 09:24:23 -08:00
Jeff Widman
39ac97a7e0 pycodestyle fixes 2020-02-18 01:21:40 -08:00
Jeff Widman
a5cb5a709f Bump version for development 2020-02-18 01:19:49 -08:00
Jeff Widman
02064c76ed Release 0.11.0 2020-02-18 01:11:19 -08:00
Jeff Widman
d713732807 Cleanup tox/travis
* Switch to python 3.8 in Travis. I tried to add 3.8 while keeping 3.7
and 3.6, but ran into issues with Travis config, so instead just bumped
straight to 3.8. Long term I'd like to explore moving to Azure
Pipelines, but don't have the time to figure that out just yet.
* `flake8` was renamed to `pycodestyle`
* `py.test` was deprecated in favor of `pytest`
2020-02-18 00:42:39 -08:00
Jeff Widman
b92391d177 Switch to Flask's native CLI
Drop `flask_script` in favor of Flask's native CLI:
* https://flask.palletsprojects.com/en/master/cli/

This also requires changing the tests so that `pytest` mocks the env var
`FLASK_ENV` so that the test app starts in development mode. Unlike
normal test apps, we _do_ want development/debug mode, in addition to
testing mode.
2020-02-17 23:57:04 -08:00
Florian
4964ae261f RoutesList: Do not show debugtoolbar routes 2020-02-17 22:30:10 -08:00
Pierre GIRAUD
ad847299c4 Add doc for SQL syntax highlighting 2020-02-17 21:57:01 -08:00
Jeff Widman
7ce099c3d0 Remove deprecated request.is_xhr
This was removed from `werkzeug` `1.0.0`.

Details:
* https://github.com/pallets/werkzeug/issues/1077
* https://github.com/pallets/werkzeug/issues/1714 (search for `is_xhr`)

Fix #144.
2020-02-17 21:50:56 -08:00
Jeff Widman
9c7db48362 Explicitly disable SQLALCHEMY_TRACK_MODIFICATIONS
This silences deprecation warnings.
Background: https://stackoverflow.com/a/33790196/770425

Note: This code can be removed once `flask_sqlalchemy` 3.0 ships, or any
release that includes
https://github.com/pallets/flask-sqlalchemy/pull/727.
2020-02-17 21:36:01 -08:00
Tim Gates
88f15cba35 Fix simple typo: exapanded -> expanded
Closes #141
2020-02-06 14:03:36 -08:00
Matt Good
d852042ccb Merge pull request #119 from davidism/json-available
don't use flask.json_available
2018-02-07 09:52:11 -08:00
David Lord
5bd2e8a423 flask.json_available is a no-op
it is removed in Flask 1.0
2018-02-07 07:13:21 -08:00
Jeff Widman
c27256c00a Bump dev version 2017-02-12 03:33:05 -08:00
Jeff Widman
010206298e Release 0.10.1 2017-02-12 03:04:07 -08:00
Jeff Widman
678ec31229 Revert "Change docs to pull version from setup.py"
This reverts commit 45b70c952f.
This commit broke the readthedocs build because RTD is building the docs
without running setup.py. So there is no package metadata.
2017-02-12 02:48:44 -08:00
Jeff Widman
23d52703fd Make copyright string track current year 2017-02-12 02:33:47 -08:00
Jeff Widman
45b70c952f Change docs to pull version from setup.py 2017-02-12 02:32:47 -08:00
Jeff Widman
9f2c353e86 Trivial imports cleanup 2017-02-12 02:31:26 -08:00
Jeff Widman
cfe142b285 Point Flask-SQLAlchemy docs at ‘latest’ 2017-02-12 00:21:20 -08:00
Jeff Widman
19a25fd895 Add universal wheel support
Let’s roll!
2017-02-10 01:09:59 -08:00
Jeff Widman
8dcb97c05a Travis should use python 3.6 interpreter 2017-02-10 00:50:38 -08:00
Jeff Widman
b49af327cf Use containers for travis tests 2017-02-10 00:44:27 -08:00
Jeff Widman
38ab3a49c1 Test using modern python 2017-02-10 00:42:00 -08:00
Jeff Widman
9f901e34ae Remove deprecated tox arg —use-mirrors 2017-02-10 00:36:19 -08:00
Jeff Widman
f050a6b0de Use latest for flask-sqlalchemy docs rather than pinning version 2017-02-10 00:28:45 -08:00
Jeff Widman
e33f3e1c85 Update RTD links w/https & .io 2017-02-09 23:54:16 -08:00
Peter M. Landwehr
02ff95acde Add LICENSE file to MANIFEST.in / source bundle (#102) 2016-09-18 23:13:08 -07:00
Iuri de Silvio
2436239964 Additional cleanup of deprecated flask.ext.* magic imports. (#97) 2016-06-29 16:52:23 -07:00
Michael Lenzen
18a0030354 Fix deprecated import from flask.ext.sqlalchemy (#94) 2016-06-29 13:33:02 -07:00
192 changed files with 387 additions and 206 deletions

View File

@@ -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

View File

@@ -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)
------------------- -------------------

View File

@@ -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 *

View File

@@ -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/

View File

@@ -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)
} }

View File

@@ -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
------- -------

View File

@@ -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
View File

@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"

36
setup.cfg Normal file
View 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

View File

@@ -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'
]
) )

View File

@@ -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)

View 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)

View File

@@ -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', {

View File

@@ -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