mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-06 05:30:12 -06:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf21647c4b | ||
|
|
818e5f2d62 | ||
|
|
c65c6b94e5 | ||
|
|
0ca1f6b241 | ||
|
|
48de4e4a3c | ||
|
|
b139c60a60 | ||
|
|
05f23436ac | ||
|
|
7012193220 | ||
|
|
7f3defff7c | ||
|
|
969cce532d | ||
|
|
c2804c4917 | ||
|
|
56beb35c36 | ||
|
|
98bf17aa58 | ||
|
|
716f05d953 | ||
|
|
fb28aa9d61 | ||
|
|
efe447fb5f | ||
|
|
9656a2cf33 | ||
|
|
9b63ad1837 | ||
|
|
765f22126e | ||
|
|
d4a8cc963e | ||
|
|
b7f5a725cd | ||
|
|
5bf5e093bb | ||
|
|
719fe02df5 | ||
|
|
f18bcc708a | ||
|
|
95c2b86bcd | ||
|
|
b03a2e6fb3 | ||
|
|
1c39a9ce47 | ||
|
|
8c8b2bb35c | ||
|
|
a2e773124f | ||
|
|
2f8ec9027b | ||
|
|
ab9a41df6a | ||
|
|
2b1e7d9907 | ||
|
|
d0360218fd | ||
|
|
e9fd3072a9 | ||
|
|
1aedfb0e2e | ||
|
|
e6ae9d0288 | ||
|
|
62ce443f8b | ||
|
|
2b8bf9cc44 | ||
|
|
42d859534a | ||
|
|
f959951185 | ||
|
|
e1c8704444 | ||
|
|
8a4cfa5e3c | ||
|
|
51d105afad | ||
|
|
15192f19e0 | ||
|
|
5712e57869 | ||
|
|
9571d06df5 | ||
|
|
3b25e114e9 | ||
|
|
f7ae3fd591 | ||
|
|
ce02d2da3c | ||
|
|
bd346a0fc1 | ||
|
|
ed8243e17e | ||
|
|
02c99a7b64 | ||
|
|
96514793e4 | ||
|
|
ec8cc3a0ba | ||
|
|
e3c8ab0ca2 | ||
|
|
fefb32b04d | ||
|
|
b5a7c032ab | ||
|
|
6af24f5f44 | ||
|
|
b4a197f87f | ||
|
|
15b6fee933 | ||
|
|
9e03576c94 | ||
|
|
bfa48c5a2c | ||
|
|
890fd9c7fb | ||
|
|
42a9651950 | ||
|
|
ff01910f6a | ||
|
|
9cdb04edcb | ||
|
|
f546d4633b | ||
|
|
db07028aa0 | ||
|
|
d44ab40729 | ||
|
|
0d409f54f5 | ||
|
|
708df1c07a | ||
|
|
10186a4202 | ||
|
|
3cd2dceace | ||
|
|
376c3deab3 |
41
.github/workflows/tests.yml
vendored
Normal file
41
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- 'docs/**'
|
||||||
|
- '*.rst'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- 'docs/**'
|
||||||
|
- '*.rst'
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: ${{ matrix.name }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- {name: Linux, python: '3.12', os: ubuntu-latest, tox: py312}
|
||||||
|
- {name: Windows, python: '3.12', os: windows-latest, tox: py312}
|
||||||
|
- {name: Mac, python: '3.12', os: macos-latest, tox: py312}
|
||||||
|
- {name: Minimal, python: '3.12', os: ubuntu-latest, tox: minimal}
|
||||||
|
- {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311}
|
||||||
|
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
|
||||||
|
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
|
||||||
|
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
|
||||||
|
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
|
||||||
|
- {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
- name: update pip
|
||||||
|
run: |
|
||||||
|
pip install -U setuptools wheel
|
||||||
|
python -m pip install -U pip
|
||||||
|
- run: pip install tox
|
||||||
|
- run: tox -e ${{ matrix.tox }}
|
||||||
162
.gitignore
vendored
162
.gitignore
vendored
@@ -1,6 +1,160 @@
|
|||||||
*.egg-info
|
# Byte-compiled / optimized / DLL files
|
||||||
*.pyc
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
build/
|
build/
|
||||||
|
develop-eggs/
|
||||||
dist/
|
dist/
|
||||||
docs/_build
|
downloads/
|
||||||
.tox
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
|
.pdm.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "docs/_themes"]
|
|
||||||
path = docs/_themes
|
|
||||||
url = git://github.com/mitsuhiko/flask-sphinx-themes.git
|
|
||||||
37
.readthedocs.yaml
Normal file
37
.readthedocs.yaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Read the Docs configuration file for Sphinx projects
|
||||||
|
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||||
|
|
||||||
|
# Required
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
# Set the OS, Python version and other tools you might need
|
||||||
|
build:
|
||||||
|
os: ubuntu-lts-latest
|
||||||
|
tools:
|
||||||
|
python: "latest"
|
||||||
|
# You can also specify other tool versions:
|
||||||
|
# nodejs: "20"
|
||||||
|
# rust: "1.70"
|
||||||
|
# golang: "1.20"
|
||||||
|
|
||||||
|
# Build documentation in the "docs/" directory with Sphinx
|
||||||
|
sphinx:
|
||||||
|
configuration: docs/conf.py
|
||||||
|
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
|
||||||
|
# builder: "dirhtml"
|
||||||
|
# Fail on all warnings to avoid broken references
|
||||||
|
fail_on_warning: true
|
||||||
|
|
||||||
|
# Optionally build your docs in additional formats such as PDF and ePub
|
||||||
|
# formats:
|
||||||
|
# - pdf
|
||||||
|
# - epub
|
||||||
|
|
||||||
|
# Optional but recommended, declare the Python requirements required
|
||||||
|
# to build your documentation
|
||||||
|
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
||||||
|
python:
|
||||||
|
install:
|
||||||
|
- path: .
|
||||||
|
extra_requirements:
|
||||||
|
- docs
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
language: python
|
|
||||||
python: "3.8"
|
|
||||||
env:
|
|
||||||
- TOXENV=py27
|
|
||||||
- TOXENV=py38
|
|
||||||
install:
|
|
||||||
- pip install tox
|
|
||||||
script: tox
|
|
||||||
224
CHANGES.rst
224
CHANGES.rst
@@ -1,224 +0,0 @@
|
|||||||
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)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- Added new "Routes" panel displaying URL routing rules (#69, thanks Justin McKay)
|
|
||||||
- "Versions" panel displays versions of all installed packages (#49, thanks Lucas Taylor)
|
|
||||||
- SQLAlchemy displays necessary setup steps to set up query recording
|
|
||||||
- Support reformatting SQL queries if ``sqlparse`` library is available (#48, thanks Hyunjun Kim)
|
|
||||||
- Enable sorting SQLAlchemy queries (#81, thanks Eric Workman)
|
|
||||||
- Support inserting toolbar on HTML5 pages without ``</body>`` tag
|
|
||||||
- Log a warning if unable to insert the toolbar (#20, thanks Rune Halvorsen)
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Ensure numeric sorting of profiler "Calls" column
|
|
||||||
|
|
||||||
0.9.2 (2014-12-05)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- HTML escape SQL queries when syntax highlighting is not available
|
|
||||||
- Use case-insensitive comparison to normalize filenames on Windows
|
|
||||||
- Fix exception when SQL query contained non-ASCII characters
|
|
||||||
|
|
||||||
0.9.1 (2014-11-24)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Fix SQL queries with byte strings on Python 3
|
|
||||||
- Fix displaying values whose `repr()` contains unprintable characters
|
|
||||||
|
|
||||||
|
|
||||||
0.9.0 (2014-01-03)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- Python 3 compatibility (#54, thanks justinmayer and jmagnusson)
|
|
||||||
- Support .init_app() (#38)
|
|
||||||
- New "Config" panel displaying Flask config values (#51, thanks Alexey Diyan)
|
|
||||||
- Better PEP8-style formatting (#63, thanks Ivan Ivaschenko)
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Fix template editor with non-ASCII templates (#46)
|
|
||||||
|
|
||||||
|
|
||||||
0.8 (2013-02-21)
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- Use `itsdangerous <http://pythonhosted.org/itsdangerous/>`_ to sign SQL queries
|
|
||||||
- Expose the jQuery object as ``fldt.$`` so extensions can use the toolbar's
|
|
||||||
copy of jQuery (#42)
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Don't intercept redirects on XHR requests (#41)
|
|
||||||
- Fix SQL query time display as milliseconds (#36)
|
|
||||||
- Fix ``functools.partial`` error (#35)
|
|
||||||
- Fix werkzeug request logging with logging panel (#33)
|
|
||||||
- Fix SQL panel unicode encoding error (#31)
|
|
||||||
|
|
||||||
|
|
||||||
0.7.1 (2012-05-18)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- loading template editor in-place over current page
|
|
||||||
|
|
||||||
|
|
||||||
0.7 (2012-05-18)
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- Add an in-browser template editor to the template panel
|
|
||||||
- ``DEBUG_TB_PROFILER_ENABLED`` config option to enable the profiler on all
|
|
||||||
requests (normally it is user-enabled by clicking the checkmark)
|
|
||||||
|
|
||||||
|
|
||||||
0.6.3.1 (2012-04-16)
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
New release to add missing changelog for 0.6.3
|
|
||||||
|
|
||||||
|
|
||||||
0.6.3 (2012-04-16)
|
|
||||||
------------------
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Compatibility with Flask-SQLAlchemy 0.16 package name
|
|
||||||
|
|
||||||
|
|
||||||
0.6.2 (2012-02-18)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Installation issue on Windows with trailing slashes in MANIFEST.in
|
|
||||||
|
|
||||||
- JavaScript error when using conditional comments for ``<html>`` tag
|
|
||||||
(like in HTML5 Boilerplate)
|
|
||||||
|
|
||||||
|
|
||||||
0.6.1 (2012-02-15)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
|
|
||||||
- Memory leak when toolbar was enabled
|
|
||||||
|
|
||||||
- UnicodeDecodeError when request data contained binary data (e.g. session values)
|
|
||||||
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- ``DEBUG_TB_ENABLED`` config setting to explicitly enable or disable the toolbar
|
|
||||||
|
|
||||||
- ``DEBUG_TB_HOSTS`` config setting to enable toolbar only for specific remote hosts
|
|
||||||
|
|
||||||
- New logo for Flask instead of Django
|
|
||||||
|
|
||||||
- Monospaced font on table data
|
|
||||||
|
|
||||||
Thanks to kennethreitz and joeshaw for their contributions.
|
|
||||||
|
|
||||||
|
|
||||||
0.6 (2012-01-04)
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Flask 0.8 or higher is required
|
|
||||||
|
|
||||||
Enhancements:
|
|
||||||
|
|
||||||
- Flask 0.8 compatibility
|
|
||||||
|
|
||||||
Thanks to mvantellingen
|
|
||||||
6
LICENSE
6
LICENSE
@@ -4,10 +4,10 @@ All rights reserved.
|
|||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
are permitted provided that the following conditions are met:
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Flask Debug-toolbar
|
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/jazzband/django-debug-toolbar>`_
|
||||||
for Flask applications.
|
for Flask applications.
|
||||||
|
|
||||||
.. image:: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar.png?branch=master
|
.. image:: https://github.com/pallets-eco/flask-debugtoolbar/actions/workflows/tests.yml/badge.svg
|
||||||
:target: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar
|
:target: https://github.com/pallets-eco/flask-debugtoolbar/actions
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ BUILD_DATE = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_
|
|||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.viewcode',
|
'sphinx.ext.viewcode',
|
||||||
'sphinx.ext.intersphinx',
|
'sphinx.ext.intersphinx',
|
||||||
|
'pallets_sphinx_themes',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
@@ -99,7 +100,7 @@ pygments_style = 'sphinx'
|
|||||||
#modindex_common_prefix = []
|
#modindex_common_prefix = []
|
||||||
|
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {
|
||||||
'flasksqlalchemy': ('http://flask-sqlalchemy.pocoo.org/latest/', None)
|
'flasksqlalchemy': ('https://flask-sqlalchemy.palletsprojects.com/', None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,9 +113,7 @@ html_theme = 'flask'
|
|||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
# documentation.
|
# documentation.
|
||||||
html_theme_options = {
|
html_theme_options = {}
|
||||||
'index_logo': None,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
sys.path.append(os.path.abspath('_themes'))
|
sys.path.append(os.path.abspath('_themes'))
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ Name Description De
|
|||||||
``DEBUG_TB_PANELS`` List of module/class names of panels enable all built-in panels
|
``DEBUG_TB_PANELS`` List of module/class names of panels enable all built-in panels
|
||||||
``DEBUG_TB_PROFILER_ENABLED`` Enable the profiler on all requests ``False``, user-enabled
|
``DEBUG_TB_PROFILER_ENABLED`` Enable the profiler on all requests ``False``, user-enabled
|
||||||
``DEBUG_TB_TEMPLATE_EDITOR_ENABLED`` Enable the template editor ``False``
|
``DEBUG_TB_TEMPLATE_EDITOR_ENABLED`` Enable the template editor ``False``
|
||||||
|
``DEBUG_TB_PROFILER_DUMP_FILENAME`` Filename of the profiler stats dump, ``None``, no dump will be written
|
||||||
|
can be a ``str`` or a ``callable``
|
||||||
==================================== ===================================== ==========================
|
==================================== ===================================== ==========================
|
||||||
|
|
||||||
To change one of the config options, set it in the Flask app's config like::
|
To change one of the config options, set it in the Flask app's config like::
|
||||||
@@ -76,16 +78,16 @@ Panels
|
|||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Fork us `on GitHub <https://github.com/mgood/flask-debugtoolbar>`_
|
Fork us `on GitHub <https://github.com/pallets-eco/flask-debugtoolbar>`_
|
||||||
|
|
||||||
Thanks
|
Thanks
|
||||||
------
|
------
|
||||||
|
|
||||||
This was based on the original `django-debug-toolbar`_. Thanks to `Michael van Tellingen`_ for the original development of this Flask extension, and to all the `individual contributors`_.
|
This was based on the original `django-debug-toolbar`_. Thanks to `Michael van Tellingen`_ for the original development of this Flask extension, and to all the `individual contributors`_.
|
||||||
|
|
||||||
.. _django-debug-toolbar: https://github.com/django-debug-toolbar/django-debug-toolbar
|
.. _django-debug-toolbar: https://github.com/jazzband/django-debug-toolbar
|
||||||
.. _Michael van Tellingen: https://github.com/mvantellingen
|
.. _Michael van Tellingen: https://github.com/mvantellingen
|
||||||
.. _individual contributors: https://github.com/mgood/flask-debugtoolbar/graphs/contributors
|
.. _individual contributors: https://github.com/pallets-eco/flask-debugtoolbar/graphs/contributors
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ Shows SQL queries run during the current request.
|
|||||||
|
|
||||||
.. image:: _static/screenshot-sqlalchemy-panel.png
|
.. image:: _static/screenshot-sqlalchemy-panel.png
|
||||||
|
|
||||||
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/
|
.. _Flask-SQLAlchemy: https://flask-sqlalchemy.palletsprojects.com/
|
||||||
|
|
||||||
.. _Pygments: http://pygments.org/
|
.. _Pygments: https://pygments.org/
|
||||||
|
|
||||||
|
|
||||||
Logging
|
Logging
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Run using: `FLASK_ENV=development flask run`
|
# Run using: `FLASK_DEBUG=True flask run`
|
||||||
|
|
||||||
from flask import Flask, render_template, redirect, url_for
|
from flask import Flask, render_template, redirect, url_for
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
@@ -14,13 +14,12 @@ 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['SQLALCHEMY_RECORD_QUERIES'] = 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)
|
# This is no longer needed for Flask-SQLAlchemy 3.0+, if you're using 2.X you'll want to define this:
|
||||||
|
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
|
||||||
|
db = SQLAlchemy(app)
|
||||||
toolbar = DebugToolbarExtension(app)
|
toolbar = DebugToolbarExtension(app)
|
||||||
|
|
||||||
|
|
||||||
@@ -29,11 +28,6 @@ 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")
|
||||||
@@ -46,3 +40,7 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
db.create_all()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = Flask-DebugToolbar
|
name = Flask-DebugToolbar
|
||||||
version = 0.13.1
|
version = 0.15.0
|
||||||
author = Michael van Tellingen
|
author = Michael van Tellingen
|
||||||
author_email = michaelvantellingen@gmail.com
|
author_email = michaelvantellingen@gmail.com
|
||||||
maintainer = Matt Good
|
maintainer = Matt Good
|
||||||
@@ -9,9 +9,9 @@ description = A toolbar overlay for debugging Flask applications.
|
|||||||
long_description = file: README.rst
|
long_description = file: README.rst
|
||||||
long_description_content_type = text/x-rst
|
long_description_content_type = text/x-rst
|
||||||
keywords = flask, debug, toolbar
|
keywords = flask, debug, toolbar
|
||||||
url = https://github.com/flask-debugtoolbar/flask-debugtoolbar
|
url = https://github.com/pallets-eco/flask-debugtoolbar
|
||||||
project_urls =
|
project_urls =
|
||||||
Changelog = https://github.com/flask-debugtoolbar/flask-debugtoolbar/blob/master/CHANGES.rst
|
Changelog = https://github.com/pallets-eco/flask-debugtoolbar/releases
|
||||||
Documentation = https://flask-debugtoolbar.readthedocs.io/
|
Documentation = https://flask-debugtoolbar.readthedocs.io/
|
||||||
classifiers =
|
classifiers =
|
||||||
Development Status :: 4 - Beta
|
Development Status :: 4 - Beta
|
||||||
@@ -30,7 +30,7 @@ package_dir =
|
|||||||
|
|
||||||
packages = find:
|
packages = find:
|
||||||
include_package_data = True
|
include_package_data = True
|
||||||
python_requires = >=2.7
|
python_requires = >=3.7
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|||||||
10
setup.py
10
setup.py
@@ -4,9 +4,17 @@ from setuptools import setup
|
|||||||
setup(
|
setup(
|
||||||
name="Flask-DebugToolbar",
|
name="Flask-DebugToolbar",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Flask>=0.8',
|
'Flask>=2.2.0',
|
||||||
'Blinker',
|
'Blinker',
|
||||||
'itsdangerous',
|
'itsdangerous',
|
||||||
'werkzeug',
|
'werkzeug',
|
||||||
|
'MarkupSafe',
|
||||||
|
'packaging',
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"docs": [
|
||||||
|
'Sphinx>=1.2.2',
|
||||||
|
'Pallets-Sphinx-Themes',
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
import contextvars
|
||||||
import os
|
import os
|
||||||
|
import urllib.parse
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
import flask
|
||||||
from flask import Blueprint, current_app, request, g, send_from_directory, url_for
|
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
|
||||||
|
|
||||||
from jinja2 import __version__ as __jinja_version__
|
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 flask_debugtoolbar.compat import iteritems
|
from flask_debugtoolbar.compat import iteritems
|
||||||
from flask_debugtoolbar.toolbar import DebugToolbar
|
from flask_debugtoolbar.toolbar import DebugToolbar
|
||||||
@@ -50,11 +53,14 @@ class DebugToolbarExtension(object):
|
|||||||
_static_dir = os.path.realpath(
|
_static_dir = os.path.realpath(
|
||||||
os.path.join(os.path.dirname(__file__), 'static'))
|
os.path.join(os.path.dirname(__file__), 'static'))
|
||||||
|
|
||||||
|
_toolbar_codes = [200, 201, 400, 401, 403, 404, 405, 500, 501, 502, 503, 504]
|
||||||
_redirect_codes = [301, 302, 303, 304]
|
_redirect_codes = [301, 302, 303, 304]
|
||||||
|
|
||||||
def __init__(self, app=None):
|
def __init__(self, app=None):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.debug_toolbars = {}
|
# Support threads running `flask.copy_current_request_context` without
|
||||||
|
# poping toolbar during `teardown_request`
|
||||||
|
self.debug_toolbars_var = contextvars.ContextVar('debug_toolbars')
|
||||||
jinja_extensions = ['jinja2.ext.i18n']
|
jinja_extensions = ['jinja2.ext.i18n']
|
||||||
|
|
||||||
if __jinja_version__[0] == '2':
|
if __jinja_version__[0] == '2':
|
||||||
@@ -66,7 +72,7 @@ class DebugToolbarExtension(object):
|
|||||||
autoescape=True,
|
autoescape=True,
|
||||||
extensions=jinja_extensions,
|
extensions=jinja_extensions,
|
||||||
loader=PackageLoader(__name__, 'templates'))
|
loader=PackageLoader(__name__, 'templates'))
|
||||||
self.jinja_env.filters['urlencode'] = url_quote_plus
|
self.jinja_env.filters['urlencode'] = urllib.parse.quote_plus
|
||||||
self.jinja_env.filters['printable'] = _printable
|
self.jinja_env.filters['printable'] = _printable
|
||||||
self.jinja_env.globals['url_for'] = url_for
|
self.jinja_env.globals['url_for'] = url_for
|
||||||
|
|
||||||
@@ -117,11 +123,12 @@ class DebugToolbarExtension(object):
|
|||||||
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
|
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
|
||||||
'flask_debugtoolbar.panels.g.GDebugPanel',
|
'flask_debugtoolbar.panels.g.GDebugPanel',
|
||||||
),
|
),
|
||||||
|
'SQLALCHEMY_RECORD_QUERIES': app.debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
"""Modified version of Flask.dispatch_request to call process_view."""
|
"""Modified version of Flask.dispatch_request to call process_view."""
|
||||||
req = _request_ctx_stack.top.request
|
req = request_ctx.request
|
||||||
app = current_app
|
app = current_app
|
||||||
|
|
||||||
if req.routing_exception is not None:
|
if req.routing_exception is not None:
|
||||||
@@ -163,11 +170,11 @@ class DebugToolbarExtension(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
real_request = request._get_current_object()
|
real_request = request._get_current_object()
|
||||||
|
self.debug_toolbars_var.set({})
|
||||||
self.debug_toolbars[real_request] = (
|
self.debug_toolbars_var.get()[real_request] = (
|
||||||
DebugToolbar(real_request, self.jinja_env))
|
DebugToolbar(real_request, self.jinja_env))
|
||||||
|
|
||||||
for panel in self.debug_toolbars[real_request].panels:
|
for panel in self.debug_toolbars_var.get()[real_request].panels:
|
||||||
panel.process_request(real_request)
|
panel.process_request(real_request)
|
||||||
|
|
||||||
def process_view(self, app, view_func, view_kwargs):
|
def process_view(self, app, view_func, view_kwargs):
|
||||||
@@ -176,7 +183,7 @@ class DebugToolbarExtension(object):
|
|||||||
"""
|
"""
|
||||||
real_request = request._get_current_object()
|
real_request = request._get_current_object()
|
||||||
try:
|
try:
|
||||||
toolbar = self.debug_toolbars[real_request]
|
toolbar = self.debug_toolbars_var.get({})[real_request]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return view_func
|
return view_func
|
||||||
|
|
||||||
@@ -189,7 +196,7 @@ class DebugToolbarExtension(object):
|
|||||||
|
|
||||||
def process_response(self, response):
|
def process_response(self, response):
|
||||||
real_request = request._get_current_object()
|
real_request = request._get_current_object()
|
||||||
if real_request not in self.debug_toolbars:
|
if real_request not in self.debug_toolbars_var.get({}):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Intercept http redirect codes and display an html page with a
|
# Intercept http redirect codes and display an html page with a
|
||||||
@@ -208,17 +215,18 @@ class DebugToolbarExtension(object):
|
|||||||
response.response = [content]
|
response.response = [content]
|
||||||
response.status_code = 200
|
response.status_code = 200
|
||||||
|
|
||||||
# If the http response code is 200 then we process to add the
|
# If the http response code is an allowed code then we process to add the
|
||||||
# toolbar to the returned html response.
|
# toolbar to the returned html response.
|
||||||
if not (response.status_code == 200 and
|
if not (response.status_code in self._toolbar_codes and
|
||||||
response.is_sequence and
|
response.is_sequence and
|
||||||
response.headers['content-type'].startswith('text/html')):
|
response.headers['content-type'].startswith('text/html')):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if 'gzip' in response.headers.get('Content-Encoding', ''):
|
content_encoding = response.headers.get('Content-Encoding')
|
||||||
response_html = gzip_decompress(response.data).decode(response.charset)
|
if content_encoding and 'gzip' in content_encoding:
|
||||||
|
response_html = gzip_decompress(response.data).decode()
|
||||||
else:
|
else:
|
||||||
response_html = response.data.decode(response.charset)
|
response_html = response.get_data(as_text=True)
|
||||||
|
|
||||||
no_case = response_html.lower()
|
no_case = response_html.lower()
|
||||||
body_end = no_case.rfind('</body>')
|
body_end = no_case.rfind('</body>')
|
||||||
@@ -234,7 +242,7 @@ class DebugToolbarExtension(object):
|
|||||||
' </body> tag not found in response.')
|
' </body> tag not found in response.')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
toolbar = self.debug_toolbars[real_request]
|
toolbar = self.debug_toolbars_var.get()[real_request]
|
||||||
|
|
||||||
for panel in toolbar.panels:
|
for panel in toolbar.panels:
|
||||||
panel.process_response(real_request, response)
|
panel.process_response(real_request, response)
|
||||||
@@ -242,8 +250,8 @@ class DebugToolbarExtension(object):
|
|||||||
toolbar_html = toolbar.render_toolbar()
|
toolbar_html = toolbar.render_toolbar()
|
||||||
|
|
||||||
content = ''.join((before, toolbar_html, after))
|
content = ''.join((before, toolbar_html, after))
|
||||||
content = content.encode(response.charset)
|
content = content.encode('utf-8')
|
||||||
if 'gzip' in response.headers.get('Content-Encoding', ''):
|
if content_encoding and 'gzip' in content_encoding:
|
||||||
content = gzip_compress(content)
|
content = gzip_compress(content)
|
||||||
response.response = [content]
|
response.response = [content]
|
||||||
response.content_length = len(content)
|
response.content_length = len(content)
|
||||||
@@ -251,7 +259,8 @@ class DebugToolbarExtension(object):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
def teardown_request(self, exc):
|
def teardown_request(self, exc):
|
||||||
self.debug_toolbars.pop(request._get_current_object(), None)
|
# debug_toolbars_var won't be set under `flask.copy_current_request_context`
|
||||||
|
self.debug_toolbars_var.get({}).pop(request._get_current_object(), None)
|
||||||
|
|
||||||
def render(self, template_name, context):
|
def render(self, template_name, context):
|
||||||
template = self.jinja_env.get_template(template_name)
|
template = self.jinja_env.get_template(template_name)
|
||||||
|
|||||||
@@ -25,6 +25,29 @@ class DebugPanel(object):
|
|||||||
# If the client enabled the panel
|
# If the client enabled the panel
|
||||||
self.is_active = False
|
self.is_active = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def init_app(cls, app):
|
||||||
|
"""Method that can be overridden by child classes.
|
||||||
|
Can be used for setting up additional URL-rules/routes.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
class UMLDiagramPanel(DebugPanel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def init_app(cls, app):
|
||||||
|
app.add_url_rule(
|
||||||
|
'/_flask_debugtoolbar_umldiagram/<path:filename>',
|
||||||
|
'_flask_debugtoolbar_umldiagram.serve_generated_image',
|
||||||
|
cls.serve_generated_image
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def serve_generated_image(cls, app):
|
||||||
|
return Response(...)
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def render(self, template_name, context):
|
def render(self, template_name, context):
|
||||||
template = self.jinja_env.get_template(template_name)
|
template = self.jinja_env.get_template(template_name)
|
||||||
return template.render(**context)
|
return template.render(**context)
|
||||||
|
|||||||
@@ -19,11 +19,10 @@ class GDebugPanel(DebugPanel):
|
|||||||
|
|
||||||
def url(self):
|
def url(self):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def content(self):
|
def content(self):
|
||||||
context = self.context.copy()
|
context = self.context.copy()
|
||||||
context.update({
|
context.update({
|
||||||
'g_content': g.__dict__
|
'g_content': g.__dict__
|
||||||
})
|
})
|
||||||
return self.render('panels/g.html', context)
|
return self.render('panels/g.html', context)
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ class ThreadTrackingHandler(logging.Handler):
|
|||||||
provided, returns a list for the current thread.
|
provided, returns a list for the current thread.
|
||||||
"""
|
"""
|
||||||
if thread is None:
|
if thread is None:
|
||||||
thread = threading.currentThread()
|
thread = threading.current_thread()
|
||||||
if thread not in self.records:
|
if thread not in self.records:
|
||||||
self.records[thread] = []
|
self.records[thread] = []
|
||||||
return self.records[thread]
|
return self.records[thread]
|
||||||
|
|
||||||
def clear_records(self, thread=None):
|
def clear_records(self, thread=None):
|
||||||
if thread is None:
|
if thread is None:
|
||||||
thread = threading.currentThread()
|
thread = threading.current_thread()
|
||||||
if thread in self.records:
|
if thread in self.records:
|
||||||
del self.records[thread]
|
del self.records[thread]
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class ProfilerDebugPanel(DebugPanel):
|
|||||||
"""
|
"""
|
||||||
Panel that displays the time a response took with cProfile output.
|
Panel that displays the time a response took with cProfile output.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = 'Profiler'
|
name = 'Profiler'
|
||||||
|
|
||||||
user_activate = True
|
user_activate = True
|
||||||
@@ -22,6 +23,9 @@ class ProfilerDebugPanel(DebugPanel):
|
|||||||
DebugPanel.__init__(self, jinja_env, context=context)
|
DebugPanel.__init__(self, jinja_env, context=context)
|
||||||
if current_app.config.get('DEBUG_TB_PROFILER_ENABLED'):
|
if current_app.config.get('DEBUG_TB_PROFILER_ENABLED'):
|
||||||
self.is_active = True
|
self.is_active = True
|
||||||
|
self.dump_filename = current_app.config.get(
|
||||||
|
"DEBUG_TB_PROFILER_DUMP_FILENAME"
|
||||||
|
)
|
||||||
|
|
||||||
def has_content(self):
|
def has_content(self):
|
||||||
return bool(self.profiler)
|
return bool(self.profiler)
|
||||||
@@ -73,7 +77,7 @@ class ProfilerDebugPanel(DebugPanel):
|
|||||||
# Cumulative time
|
# Cumulative time
|
||||||
current['cumtime'] = info[3] * 1000
|
current['cumtime'] = info[3] * 1000
|
||||||
|
|
||||||
# Quotient of the cumulative time divded by the number of
|
# Quotient of the cumulative time divided by the number of
|
||||||
# primitive calls.
|
# primitive calls.
|
||||||
if info[0]:
|
if info[0]:
|
||||||
current['percall_cum'] = info[3] * 1000 / info[0]
|
current['percall_cum'] = info[3] * 1000 / info[0]
|
||||||
@@ -88,13 +92,20 @@ class ProfilerDebugPanel(DebugPanel):
|
|||||||
|
|
||||||
self.stats = stats
|
self.stats = stats
|
||||||
self.function_calls = function_calls
|
self.function_calls = function_calls
|
||||||
# destroy the profiler just in case
|
|
||||||
|
if self.dump_filename:
|
||||||
|
if callable(self.dump_filename):
|
||||||
|
filename = self.dump_filename()
|
||||||
|
else:
|
||||||
|
filename = self.dump_filename
|
||||||
|
self.profiler.dump_stats(filename)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def title(self):
|
def title(self):
|
||||||
if not self.is_active:
|
if not self.is_active:
|
||||||
return "Profiler not active"
|
return "Profiler not active"
|
||||||
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
|
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)
|
||||||
|
|
||||||
def nav_title(self):
|
def nav_title(self):
|
||||||
return 'Profiler'
|
return 'Profiler'
|
||||||
@@ -102,7 +113,7 @@ class ProfilerDebugPanel(DebugPanel):
|
|||||||
def nav_subtitle(self):
|
def nav_subtitle(self):
|
||||||
if not self.is_active:
|
if not self.is_active:
|
||||||
return "in-active"
|
return "in-active"
|
||||||
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
|
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)
|
||||||
|
|
||||||
def url(self):
|
def url(self):
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
try:
|
try:
|
||||||
from flask_sqlalchemy import get_debug_queries, SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sqlalchemy_available = False
|
sqlalchemy_available = False
|
||||||
get_debug_queries = SQLAlchemy = None
|
get_recorded_queries = SQLAlchemy = None
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
|
from flask_sqlalchemy.record_queries import get_recorded_queries
|
||||||
|
debug_enables_record_queries = False
|
||||||
|
except ImportError:
|
||||||
|
# For flask_sqlalchemy < 3.0.0
|
||||||
|
from flask_sqlalchemy import get_debug_queries as get_recorded_queries
|
||||||
|
|
||||||
|
# flask_sqlalchemy < 3.0.0 automatically enabled
|
||||||
|
# SQLALCHEMY_RECORD_QUERIES in debug or test mode
|
||||||
|
debug_enables_record_queries = True
|
||||||
|
|
||||||
|
location_property = 'context'
|
||||||
|
else:
|
||||||
|
location_property = 'location'
|
||||||
sqlalchemy_available = True
|
sqlalchemy_available = True
|
||||||
|
|
||||||
from flask import request, current_app, abort, g
|
from flask import request, current_app, abort, g
|
||||||
@@ -12,7 +26,6 @@ from flask_debugtoolbar.panels import DebugPanel
|
|||||||
from flask_debugtoolbar.utils import format_fname, format_sql
|
from flask_debugtoolbar.utils import format_fname, format_sql
|
||||||
import itsdangerous
|
import itsdangerous
|
||||||
|
|
||||||
|
|
||||||
_ = lambda x: x
|
_ = lambda x: x
|
||||||
|
|
||||||
|
|
||||||
@@ -54,8 +67,10 @@ def extension_used():
|
|||||||
|
|
||||||
|
|
||||||
def recording_enabled():
|
def recording_enabled():
|
||||||
return (current_app.debug
|
return (
|
||||||
or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
|
(debug_enables_record_queries and current_app.debug) or
|
||||||
|
current_app.config.get('SQLALCHEMY_RECORD_QUERIES')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_available():
|
def is_available():
|
||||||
@@ -63,8 +78,8 @@ def is_available():
|
|||||||
|
|
||||||
|
|
||||||
def get_queries():
|
def get_queries():
|
||||||
if get_debug_queries:
|
if get_recorded_queries:
|
||||||
return get_debug_queries()
|
return get_recorded_queries()
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -118,11 +133,12 @@ class SQLAlchemyDebugPanel(DebugPanel):
|
|||||||
'duration': query.duration,
|
'duration': query.duration,
|
||||||
'sql': format_sql(query.statement, query.parameters),
|
'sql': format_sql(query.statement, query.parameters),
|
||||||
'signed_query': dump_query(query.statement, query.parameters),
|
'signed_query': dump_query(query.statement, query.parameters),
|
||||||
'context_long': query.context,
|
'location_long': getattr(query, location_property),
|
||||||
'context': format_fname(query.context)
|
'location': format_fname(getattr(query, location_property))
|
||||||
})
|
})
|
||||||
return self.render('panels/sqlalchemy.html', {'queries': data})
|
return self.render('panels/sqlalchemy.html', {'queries': data})
|
||||||
|
|
||||||
|
|
||||||
# Panel views
|
# Panel views
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ class TimerDebugPanel(DebugPanel):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
def _elapsed_ru(self, name):
|
def _elapsed_ru(self, name):
|
||||||
return (getattr(self._end_rusage, name)
|
return (getattr(self._end_rusage, name) - getattr(self._start_rusage, name))
|
||||||
- getattr(self._start_rusage, name))
|
|
||||||
|
|
||||||
def content(self):
|
def content(self):
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import os
|
import os
|
||||||
from distutils.sysconfig import get_python_lib
|
from sysconfig import get_path
|
||||||
|
|
||||||
from flask import __version__ as flask_version
|
|
||||||
from flask_debugtoolbar.panels import DebugPanel
|
from flask_debugtoolbar.panels import DebugPanel
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python 3.8+
|
||||||
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
flask_version = version('flask')
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
flask_version = pkg_resources.get_distribution('flask').version
|
||||||
|
|
||||||
_ = lambda x: x
|
_ = lambda x: x
|
||||||
|
|
||||||
|
|
||||||
def relpath(location, python_lib):
|
|
||||||
location = os.path.normpath(location)
|
|
||||||
relative = os.path.relpath(location, python_lib)
|
|
||||||
if relative == os.path.curdir:
|
|
||||||
return ''
|
|
||||||
elif relative.startswith(os.path.pardir):
|
|
||||||
return location
|
|
||||||
return relative
|
|
||||||
|
|
||||||
|
|
||||||
class VersionDebugPanel(DebugPanel):
|
class VersionDebugPanel(DebugPanel):
|
||||||
"""
|
"""
|
||||||
Panel that displays the Flask version.
|
Panel that displays the Flask version.
|
||||||
@@ -38,15 +38,14 @@ class VersionDebugPanel(DebugPanel):
|
|||||||
|
|
||||||
def content(self):
|
def content(self):
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import importlib.metadata
|
||||||
except ImportError:
|
except ImportError:
|
||||||
packages = []
|
packages = []
|
||||||
else:
|
else:
|
||||||
packages = sorted(pkg_resources.working_set,
|
packages_metadata = [p.metadata for p in importlib.metadata.distributions()]
|
||||||
key=lambda p: p.project_name.lower())
|
packages = sorted(packages_metadata, key=lambda p: p['Name'].lower())
|
||||||
|
|
||||||
return self.render('panels/versions.html', {
|
return self.render('panels/versions.html', {
|
||||||
'packages': packages,
|
'packages': packages,
|
||||||
'python_lib': os.path.normpath(get_python_lib()),
|
'python_lib_dir': os.path.normpath(get_path('platlib')),
|
||||||
'relpath': relpath,
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ CodeMirror.defineMode('rst', function(config, options) {
|
|||||||
setState(state, inline, {
|
setState(state, inline, {
|
||||||
ch: orig, // inline() has to know what to search for
|
ch: orig, // inline() has to know what to search for
|
||||||
wide: wide, // are we looking for `ch` or `chch`
|
wide: wide, // are we looking for `ch` or `chch`
|
||||||
prev: null, // terminator must not be preceeded with whitespace
|
prev: null, // terminator must not be preceded with whitespace
|
||||||
token: token // I don't want to recompute this all the time
|
token: token // I don't want to recompute this all the time
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {
|
|||||||
// function. Each keyword is a property of the keywords object whose
|
// function. Each keyword is a property of the keywords object whose
|
||||||
// value is {type: atype, style: astyle}
|
// value is {type: atype, style: astyle}
|
||||||
var keywords = function(){
|
var keywords = function(){
|
||||||
// conveinence functions used to build keywords object
|
// convenience functions used to build keywords object
|
||||||
function kw(type) {return {type: type, style: "keyword"};}
|
function kw(type) {return {type: type, style: "keyword"};}
|
||||||
var A = kw("keyword a")
|
var A = kw("keyword a")
|
||||||
, B = kw("keyword b")
|
, B = kw("keyword b")
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
bottom:0;
|
bottom:0;
|
||||||
right:0;
|
right:0;
|
||||||
opacity:0.9;
|
opacity:0.9;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#flDebug #flDebugToolbar small {
|
#flDebug #flDebugToolbar small {
|
||||||
@@ -167,6 +168,7 @@
|
|||||||
left:0px;
|
left:0px;
|
||||||
background-color:#eee;
|
background-color:#eee;
|
||||||
color:#666;
|
color:#666;
|
||||||
|
overflow: auto;
|
||||||
z-index:100000000;
|
z-index:100000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,11 +202,11 @@
|
|||||||
padding:0 0 0 20px;
|
padding:0 0 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#flDebug .flDebugPanelContent .scroll {
|
#flDebug .flDebugPanelContent .flDebugScroll {
|
||||||
height:100%;
|
height:100%;
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
display:block;
|
display:block;
|
||||||
padding:0 10px 0 0;
|
padding:0 10px 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#flDebug h3 {
|
#flDebug h3 {
|
||||||
|
|||||||
1018
src/flask_debugtoolbar/static/js/jquery-migrate.js
vendored
Normal file
1018
src/flask_debugtoolbar/static/js/jquery-migrate.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10724
src/flask_debugtoolbar/static/js/jquery.js
vendored
10724
src/flask_debugtoolbar/static/js/jquery.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
|||||||
init: function() {
|
init: function() {
|
||||||
$('#flDebug').show();
|
$('#flDebug').show();
|
||||||
var current = null;
|
var current = null;
|
||||||
$('#flDebugPanelList li a').click(function() {
|
$('#flDebugPanelList li a').on('click', function() {
|
||||||
if (!this.className) {
|
if (!this.className) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebugPanelList li .flDebugSwitch').click(function() {
|
$('#flDebugPanelList li .flDebugSwitch').on('click', function() {
|
||||||
var $panel = $(this).parent();
|
var $panel = $(this).parent();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var dom_id = $panel.attr('id');
|
var dom_id = $panel.attr('id');
|
||||||
@@ -52,12 +52,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#flDebug a.flDebugClose').click(function() {
|
$('#flDebug a.flDebugClose').on('click', function() {
|
||||||
$(document).trigger('close.flDebug');
|
$(document).trigger('close.flDebug');
|
||||||
$('#flDebugToolbar li').removeClass('flDebugActive');
|
$('#flDebugToolbar li').removeClass('flDebugActive');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebug a.flDebugRemoteCall').click(function() {
|
$('#flDebug a.flDebugRemoteCall').on('click', function() {
|
||||||
$('#flDebugWindow').load(this.href, {}, function() {
|
$('#flDebugWindow').load(this.href, {}, function() {
|
||||||
$('#flDebugWindow a.flDebugBack').click(function() {
|
$('#flDebugWindow a.flDebugBack').click(function() {
|
||||||
$(this).parent().parent().hide();
|
$(this).parent().parent().hide();
|
||||||
@@ -67,24 +67,24 @@
|
|||||||
$('#flDebugWindow').show();
|
$('#flDebugWindow').show();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebugTemplatePanel a.flDebugTemplateShowContext').click(function() {
|
$('#flDebugTemplatePanel a.flDebugTemplateShowContext').on('click', function() {
|
||||||
fldt.toggle_arrow($(this).children('.flDebugToggleArrow'))
|
fldt.toggle_arrow($(this).children('.flDebugToggleArrow'))
|
||||||
fldt.toggle_content($(this).parent().next());
|
fldt.toggle_content($(this).parent().next());
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebugSQLPanel a.flDebugShowStacktrace').click(function() {
|
$('#flDebugSQLPanel a.flDebugShowStacktrace').on('click', function() {
|
||||||
fldt.toggle_content($('.flDebugHideStacktraceDiv', $(this).parents('tr')));
|
fldt.toggle_content($('.flDebugHideStacktraceDiv', $(this).parents('tr')));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebugHideToolBarButton').click(function() {
|
$('#flDebugHideToolBarButton').on('click', function() {
|
||||||
fldt.hide_toolbar(true);
|
fldt.hide_toolbar(true);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#flDebugShowToolBarButton').click(function() {
|
$('#flDebugShowToolBarButton').on('click', function() {
|
||||||
fldt.show_toolbar();
|
fldt.show_toolbar();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$(document).bind('close.flDebug', function() {
|
$(document).on('close.flDebug', function() {
|
||||||
// If a sub-panel is open, close that
|
// If a sub-panel is open, close that
|
||||||
if ($('#flDebugWindow').is(':visible')) {
|
if ($('#flDebugWindow').is(':visible')) {
|
||||||
$('#flDebugWindow').hide();
|
$('#flDebugWindow').hide();
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
},
|
},
|
||||||
show_toolbar: function(animate) {
|
show_toolbar: function(animate) {
|
||||||
// Set up keybindings
|
// Set up keybindings
|
||||||
$(document).bind('keydown.flDebug', function(e) {
|
$(document).on('keydown.flDebug', function(e) {
|
||||||
if (e.keyCode == 27) {
|
if (e.keyCode == 27) {
|
||||||
fldt.close();
|
fldt.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<div id="flDebug" style="display:none;">
|
<div id="flDebug" style="display:none;" role="navigation">
|
||||||
<script type="text/javascript">var DEBUG_TOOLBAR_STATIC_PATH = '{{ static_path }}'</script>
|
<script type="text/javascript">var DEBUG_TOOLBAR_STATIC_PATH = '{{ static_path }}'</script>
|
||||||
<script type="text/javascript" src="{{ static_path }}js/jquery.js"></script>
|
<script type="text/javascript" src="{{ static_path }}js/jquery.js"></script>
|
||||||
|
<!-- Temporarily adding jquery-migrate during the Jquery upgrade process, this can be removed post-upgrade -->
|
||||||
|
<script src="{{ static_path }}js/jquery-migrate.js"></script>
|
||||||
<script type="text/javascript" src="{{ static_path }}js/jquery.tablesorter.js"></script>
|
<script type="text/javascript" src="{{ static_path }}js/jquery.tablesorter.js"></script>
|
||||||
<script type="text/javascript" src="{{ static_path }}js/toolbar.js"></script>
|
<script type="text/javascript" src="{{ static_path }}js/toolbar.js"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,4 +13,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -22,5 +22,3 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p>No messages logged.</p>
|
<p>No messages logged.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
<a class="flDebugRemoteCall" href="{{ url_for('debugtoolbar.sql_select', explain=True, query=query.signed_query, duration=query.duration )}}">EXPLAIN</a><br />
|
<a class="flDebugRemoteCall" href="{{ url_for('debugtoolbar.sql_select', explain=True, query=query.signed_query, duration=query.duration )}}">EXPLAIN</a><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td title="{{ query.context_long }}">
|
<td title="{{ query.location_long }}">
|
||||||
{{ query.context }}
|
{{ query.location }}
|
||||||
</td>
|
</td>
|
||||||
<td class="flDebugSyntax">
|
<td class="flDebugSyntax">
|
||||||
<div class="flDebugSqlWrap">
|
<div class="flDebugSqlWrap">
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<h5>Configure Flask-SQLAlchemy:</h5>
|
<h5>Configure Flask-SQLAlchemy:</h5>
|
||||||
<p>
|
<p>
|
||||||
The Flask-SQLAlchemy extension needs to be configured for this application.
|
The Flask-SQLAlchemy extension needs to be configured for this application.
|
||||||
Please see the <a href="https://flask-sqlalchemy.palletsprojects.com/en/master/quickstart/">
|
Please see the <a href="https://flask-sqlalchemy.palletsprojects.com/quickstart/">
|
||||||
Flask-SQLAlchemy documentation</a> for details.
|
Flask-SQLAlchemy documentation</a> for details.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<h3>SQL Details</h3>
|
<h3>SQL Details</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="flDebugPanelContent">
|
<div class="flDebugPanelContent">
|
||||||
<div class="scroll">
|
<div class="flDebugScroll">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Executed SQL</dt>
|
<dt>Executed SQL</dt>
|
||||||
<dd>{{ sql }}</dd>
|
<dd>{{ sql }}</dd>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
<title>Editing {{ templates[0].name }}</title>
|
<title>Editing {{ templates[0].name }}</title>
|
||||||
<script src="{{ static_path }}js/jquery.js"></script>
|
<script src="{{ static_path }}js/jquery.js"></script>
|
||||||
|
<!-- Temporarily adding jquery-migrate during the Jquery upgrade process, this can be removed post-upgrade -->
|
||||||
|
<script src="{{ static_path }}js/jquery-migrate.js"></script>
|
||||||
<link rel="stylesheet" href="{{ static_path }}codemirror/codemirror.css">
|
<link rel="stylesheet" href="{{ static_path }}codemirror/codemirror.css">
|
||||||
<link rel="stylesheet" href="{{ static_path }}codemirror/theme/rubyblue.css">
|
<link rel="stylesheet" href="{{ static_path }}codemirror/theme/rubyblue.css">
|
||||||
<link rel="stylesheet" href="{{ static_path }}codemirror/theme/lesser-dark.css">
|
<link rel="stylesheet" href="{{ static_path }}codemirror/theme/lesser-dark.css">
|
||||||
@@ -116,7 +118,7 @@
|
|||||||
delay = setTimeout(updatePreview, 300);
|
delay = setTimeout(updatePreview, 300);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var previewFrame = document.getElementById('flDebugPreview');
|
var previewFrame = document.getElementById('flDebugPreview');
|
||||||
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
|
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
|
||||||
var errorLine = null;
|
var errorLine = null;
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<h4>Installed Packages</h4>
|
<h4>Installed Packages</h4>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Installation paths relative to:
|
Current Site Packages Directory:
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
{{ python_lib }}
|
{{ python_lib_dir }}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
@@ -12,21 +12,23 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Package</th>
|
<th>Package</th>
|
||||||
<th>Version</th>
|
<th>Version</th>
|
||||||
<th>Installed Path</th>
|
<th>Homepage</th>
|
||||||
|
<th>Summary</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for package in packages %}
|
{% for package in packages %}
|
||||||
<tr class="{{ loop.cycle('flDebugOdd', 'flDebugEven') }}">
|
<tr class="{{ loop.cycle('flDebugOdd', 'flDebugEven') }}">
|
||||||
<td>{{ package.project_name }}</td>
|
<td>{{ package.get('Name') }}</td>
|
||||||
<td>{{ package.version }}</td>
|
<td>{{ package.get('Version') }}</td>
|
||||||
<td>{{ relpath(package.location, python_lib) }}</td>
|
<td>{{ package.get('Home-page') }}</td>
|
||||||
|
<td>{{ package.get('Summary') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>setuptools</td>
|
<td>Python 3.8</td>
|
||||||
<td>NOT INSTALLED</td>
|
<td>NOT INSTALLED</td>
|
||||||
<td>Install setuptools to display installed packages and version information</td>
|
<td>This panel requires Python >= 3.8 in order to display installed packages and version information.</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class DebugToolbar(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load_panels(cls, app):
|
def load_panels(cls, app):
|
||||||
for panel_class in cls._iter_panels(app):
|
for panel_class in cls._iter_panels(app):
|
||||||
# just loop to make sure they've been loaded
|
# Call `.init_app()` on panels
|
||||||
pass
|
panel_class.init_app(app)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _iter_panels(cls, app):
|
def _iter_panels(cls, app):
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_SQLPARSE = False
|
HAVE_SQLPARSE = False
|
||||||
|
|
||||||
from flask import current_app, Markup
|
from flask import current_app
|
||||||
|
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
|
|
||||||
def format_fname(value):
|
def format_fname(value):
|
||||||
@@ -86,6 +88,7 @@ def format_sql(query, args):
|
|||||||
SqlLexer(),
|
SqlLexer(),
|
||||||
HtmlFormatter(noclasses=True, style=PYGMENT_STYLE)))
|
HtmlFormatter(noclasses=True, style=PYGMENT_STYLE)))
|
||||||
|
|
||||||
|
|
||||||
def gzip_compress(data, compresslevel=6):
|
def gzip_compress(data, compresslevel=6):
|
||||||
buff = io.BytesIO()
|
buff = io.BytesIO()
|
||||||
with gzip.GzipFile(fileobj=buff, mode='wb', compresslevel=compresslevel) as f:
|
with gzip.GzipFile(fileobj=buff, mode='wb', compresslevel=compresslevel) as f:
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
|
|
||||||
from flask_debugtoolbar import DebugToolbarExtension
|
from flask_debugtoolbar import DebugToolbarExtension
|
||||||
|
|
||||||
|
|
||||||
app = Flask('basic_app')
|
app = Flask('basic_app')
|
||||||
|
app.config['DEBUG'] = True
|
||||||
app.config['SECRET_KEY'] = 'abc123'
|
app.config['SECRET_KEY'] = 'abc123'
|
||||||
|
app.config['SQLALCHEMY_RECORD_QUERIES'] = True
|
||||||
# TODO: This can be removed once flask_sqlalchemy 3.0 ships
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
# This is no longer needed for Flask-SQLAlchemy 3.0+,
|
||||||
|
# if you're using 2.X you'll want to define this:
|
||||||
|
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
|
||||||
# make sure these are printable in the config panel
|
# make sure these are printable in the config panel
|
||||||
app.config['BYTES_VALUE'] = b'\x00'
|
app.config['BYTES_VALUE'] = b'\x00'
|
||||||
@@ -23,12 +25,11 @@ class Foo(db.Model):
|
|||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
|
|
||||||
@app.before_first_request
|
|
||||||
def setup():
|
|
||||||
db.create_all()
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
Foo.query.filter_by(id=1).all()
|
Foo.query.filter_by(id=1).all()
|
||||||
return render_template('basic_app.html')
|
return render_template('basic_app.html')
|
||||||
|
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
db.create_all()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<body>Hello world</body>
|
<body>Hello world</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from flask_debugtoolbar import _printable
|
from flask_debugtoolbar import _printable
|
||||||
|
|
||||||
|
|
||||||
@@ -16,26 +14,3 @@ def test_basic_app():
|
|||||||
index = app.get('/')
|
index = app.get('/')
|
||||||
assert index.status_code == 200
|
assert index.status_code == 200
|
||||||
assert b'<div id="flDebug"' in index.data
|
assert b'<div id="flDebug"' in index.data
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info >= (3,),
|
|
||||||
reason='test only applies to Python 2')
|
|
||||||
def test_printable_unicode():
|
|
||||||
class UnicodeRepr(object):
|
|
||||||
def __repr__(self):
|
|
||||||
return u'\uffff'
|
|
||||||
|
|
||||||
printable = _printable(UnicodeRepr())
|
|
||||||
assert "raised UnicodeEncodeError: 'ascii' codec" in printable
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info >= (3,),
|
|
||||||
reason='test only applies to Python 2')
|
|
||||||
def test_printable_non_ascii():
|
|
||||||
class NonAsciiRepr(object):
|
|
||||||
def __repr__(self):
|
|
||||||
return 'a\xffb'
|
|
||||||
|
|
||||||
printable = u'%s' % _printable(NonAsciiRepr())
|
|
||||||
# should replace \xff with the unicode ? character
|
|
||||||
assert printable == u'a\ufffdb'
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import ntpath
|
import ntpath
|
||||||
import posixpath
|
import posixpath
|
||||||
|
|
||||||
from flask import Markup
|
from markupsafe import Markup
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from flask_debugtoolbar.utils import (_relative_paths, _shortest_relative_path,
|
from flask_debugtoolbar.utils import (_relative_paths, _shortest_relative_path,
|
||||||
|
|||||||
16
tox.ini
16
tox.ini
@@ -1,5 +1,9 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27,py36,py37,py38,stylecheck
|
envlist =
|
||||||
|
py3{12,11,10,9,8,7}
|
||||||
|
stylecheck
|
||||||
|
minimal
|
||||||
|
skip_missing_interpreters = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
@@ -9,11 +13,19 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
pytest
|
pytest
|
||||||
|
|
||||||
|
[testenv:minimal]
|
||||||
|
deps =
|
||||||
|
.
|
||||||
|
commands =
|
||||||
|
python -c "from flask_debugtoolbar import DebugToolbarExtension"
|
||||||
|
|
||||||
[testenv:stylecheck]
|
[testenv:stylecheck]
|
||||||
deps =
|
deps =
|
||||||
pycodestyle
|
pycodestyle
|
||||||
commands =
|
commands =
|
||||||
pycodestyle flask_debugtoolbar test
|
# E731: do not assign a lambda expression, use a def
|
||||||
|
# W504: line break after binary operator
|
||||||
|
pycodestyle src/flask_debugtoolbar test --ignore=E731,W504
|
||||||
|
|
||||||
[pycodestyle]
|
[pycodestyle]
|
||||||
max-line-length = 100
|
max-line-length = 100
|
||||||
|
|||||||
Reference in New Issue
Block a user