mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2025-12-31 02:29:33 -06:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02064c76ed | ||
|
|
d713732807 | ||
|
|
b92391d177 | ||
|
|
4964ae261f | ||
|
|
ad847299c4 | ||
|
|
7ce099c3d0 | ||
|
|
9c7db48362 | ||
|
|
88f15cba35 | ||
|
|
d852042ccb | ||
|
|
5bd2e8a423 | ||
|
|
c27256c00a |
@@ -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
|
||||
|
||||
17
CHANGES.rst
17
CHANGES.rst
@@ -1,6 +1,23 @@
|
||||
Changes
|
||||
=======
|
||||
|
||||
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)
|
||||
-------------------
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ copyright = u'2012-{0}'.format(BUILD_DATE.year)
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.10'
|
||||
version = '0.11.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.10.1'
|
||||
release = '0.11.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -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
|
||||
-------
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -42,8 +43,6 @@ def redirect_example():
|
||||
response.set_cookie('test_cookie', '1')
|
||||
return response
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
db.create_all()
|
||||
|
||||
manager = Manager(app)
|
||||
manager.run()
|
||||
@@ -178,8 +178,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:
|
||||
|
||||
@@ -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', {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -6,16 +6,11 @@
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
{% if not json_available or not sqlalchemy_available %}
|
||||
{% if not sqlalchemy_available %}
|
||||
<li>
|
||||
<h5>Install required libraries:</h5>
|
||||
<ul>
|
||||
{% if not json_available %}
|
||||
<li>simplejson</li>
|
||||
{% endif %}
|
||||
{% if not sqlalchemy_available %}
|
||||
<li>Flask-SQLAlchemy</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
2
setup.py
2
setup.py
@@ -14,7 +14,7 @@ except:
|
||||
|
||||
setup(
|
||||
name='Flask-DebugToolbar',
|
||||
version='0.10.1',
|
||||
version='0.11.0',
|
||||
url='https://flask-debugtoolbar.readthedocs.io/',
|
||||
license='BSD',
|
||||
author='Michael van Tellingen',
|
||||
|
||||
@@ -5,9 +5,11 @@ from flask_debugtoolbar import DebugToolbarExtension
|
||||
|
||||
|
||||
app = Flask('basic_app')
|
||||
app.debug = True
|
||||
app.config['SECRET_KEY'] = 'abc123'
|
||||
|
||||
# TODO: This can be removed once flask_sqlalchemy 3.0 ships
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
|
||||
# make sure these are printable in the config panel
|
||||
app.config['BYTES_VALUE'] = b'\x00'
|
||||
app.config['UNICODE_VALUE'] = u'\uffff'
|
||||
@@ -26,7 +28,3 @@ def index():
|
||||
db.create_all()
|
||||
Foo.query.filter_by(id=1).all()
|
||||
return render_template('basic_app.html')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
||||
5
test/conftest.py
Normal file
5
test/conftest.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import pytest
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_env_development(monkeypatch):
|
||||
monkeypatch.setenv("FLASK_ENV", "development")
|
||||
10
tox.ini
10
tox.ini
@@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = py27,py36,stylecheck
|
||||
envlist = py27,py36,py37,py38,stylecheck
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
@@ -7,13 +7,13 @@ deps =
|
||||
Flask-SQLAlchemy
|
||||
Pygments
|
||||
commands =
|
||||
py.test
|
||||
pytest
|
||||
|
||||
[testenv:stylecheck]
|
||||
deps =
|
||||
flake8
|
||||
pycodestyle
|
||||
commands =
|
||||
flake8 flask_debugtoolbar test
|
||||
pycodestyle flask_debugtoolbar test
|
||||
|
||||
[flake8]
|
||||
[pycodestyle]
|
||||
max-line-length = 100
|
||||
|
||||
Reference in New Issue
Block a user