33 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
191 changed files with 353 additions and 192 deletions

View File

@@ -1,9 +1,9 @@
sudo: false
language: python
python: "3.6"
python: "3.8"
env:
- TOXENV=py27
- TOXENV=py36
- TOXENV=py38
install:
- pip install tox
script: tox

View File

@@ -1,6 +1,73 @@
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)
-------------------

View File

@@ -1,3 +1,3 @@
include LICENSE
recursive-include flask_debugtoolbar/templates *.html
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>`_
for Flask applications.
.. image:: https://travis-ci.org/mgood/flask-debugtoolbar.png?branch=master
:target: https://travis-ci.org/mgood/flask-debugtoolbar
.. image:: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar.png?branch=master
:target: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar
Installation

View File

@@ -13,9 +13,12 @@
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())))
@@ -56,10 +59,10 @@ copyright = u'2012-{0}'.format(BUILD_DATE.year)
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.10'
# The full version, including alpha/beta/rc tags.
release = '0.10.1'
release = flask_debugtoolbar.__version__
# The short X.Y version.
version = '.'.join(release.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -13,7 +13,7 @@ Time
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
@@ -72,10 +72,14 @@ Shows SQL queries run during the current request.
For additional details on query recording see the
:py:func:`~flask_sqlalchemy.get_debug_queries` documentation.
.. note:: SQL syntax highlighting requires `Pygments`_ to be installed.
.. image:: _static/screenshot-sqlalchemy-panel.png
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/
.. _Pygments: http://pygments.org/
Logging
-------

View File

@@ -1,8 +1,6 @@
import sys
sys.path.insert(0, '.')
# Run using: `FLASK_ENV=development flask run`
from flask import Flask, render_template, redirect, url_for
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
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['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'
db = SQLAlchemy(app)
@@ -28,6 +29,11 @@ class ExampleModel(db.Model):
value = db.Column(db.String(100), primary_key=True)
@app.before_first_request
def setup():
db.create_all()
@app.route('/')
def index():
app.logger.info("Hello there")
@@ -37,13 +43,6 @@ def index():
@app.route('/redirect')
def redirect_example():
response = redirect(url_for('index'))
response.set_cookie('test_cookie', '1')
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"

View File

@@ -1,2 +1,36 @@
[bdist_wheel]
universal=1
[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
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(
name='Flask-DebugToolbar',
version='0.10.1',
url='https://flask-debugtoolbar.readthedocs.io/',
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'
],
name="Flask-DebugToolbar",
install_requires=[
'Flask>=0.8',
'Blinker',
'itsdangerous',
'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 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 jinja2 import __version__ as __jinja_version__
from jinja2 import Environment, PackageLoader
from werkzeug.urls import url_quote_plus
from flask_debugtoolbar.compat import iteritems
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__)
@@ -44,15 +55,20 @@ class DebugToolbarExtension(object):
def __init__(self, app=None):
self.app = app
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
# for static data
self.jinja_env = Environment(
autoescape=True,
extensions=['jinja2.ext.i18n', 'jinja2.ext.with_'],
extensions=jinja_extensions,
loader=PackageLoader(__name__, 'templates'))
self.jinja_env.filters['urlencode'] = url_quote_plus
self.jinja_env.filters['printable'] = _printable
self.jinja_env.globals['url_for'] = url_for
if app is not None:
self.init_app(app)
@@ -99,6 +115,7 @@ class DebugToolbarExtension(object):
'flask_debugtoolbar.panels.logger.LoggingPanel',
'flask_debugtoolbar.panels.route_list.RouteListDebugPanel',
'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
# link to the target.
if current_app.config['DEBUG_TB_INTERCEPT_REDIRECTS']:
if (response.status_code in self._redirect_codes and
not real_request.is_xhr):
if response.status_code in self._redirect_codes:
redirect_to = response.location
redirect_code = response.status_code
if redirect_to:
@@ -199,7 +215,10 @@ class DebugToolbarExtension(object):
response.headers['content-type'].startswith('text/html')):
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()
body_end = no_case.rfind('</body>')
@@ -224,6 +243,8 @@ class DebugToolbarExtension(object):
content = ''.join((before, toolbar_html, after))
content = content.encode(response.charset)
if 'gzip' in response.headers.get('Content-Encoding', ''):
content = gzip_compress(content)
response.response = [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')
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):
return self.render('panels/route_list.html', {

View File

@@ -6,7 +6,7 @@ except ImportError:
else:
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.panels import DebugPanel
from flask_debugtoolbar.utils import format_fname, format_sql
@@ -59,8 +59,7 @@ def recording_enabled():
def is_available():
return (json_available and sqlalchemy_available
and extension_used() and recording_enabled())
return sqlalchemy_available and extension_used() and recording_enabled()
def get_queries():
@@ -108,7 +107,6 @@ class SQLAlchemyDebugPanel(DebugPanel):
if not queries and not is_available():
return self.render('panels/sqlalchemy_error.html', {
'json_available': json_available,
'sqlalchemy_available': sqlalchemy_available,
'extension_used': extension_used(),
'recording_enabled': recording_enabled(),

Some files were not shown because too many files have changed in this diff Show More