11 Commits

Author SHA1 Message Date
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
13 changed files with 55 additions and 36 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,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)
-------------------

View File

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

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

View File

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

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(),

View File

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

View File

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

View File

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

@@ -0,0 +1,5 @@
import pytest
@pytest.fixture(autouse=True)
def mock_env_development(monkeypatch):
monkeypatch.setenv("FLASK_ENV", "development")

10
tox.ini
View File

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