mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-06 05:30:12 -06:00
Compare commits
29 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 |
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -21,12 +21,12 @@ jobs:
|
|||||||
- {name: Linux, python: '3.12', os: ubuntu-latest, tox: py312}
|
- {name: Linux, python: '3.12', os: ubuntu-latest, tox: py312}
|
||||||
- {name: Windows, python: '3.12', os: windows-latest, tox: py312}
|
- {name: Windows, python: '3.12', os: windows-latest, tox: py312}
|
||||||
- {name: Mac, python: '3.12', os: macos-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.11', python: '3.11', os: ubuntu-latest, tox: py311}
|
||||||
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
|
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
|
||||||
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
|
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
|
||||||
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
|
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
|
||||||
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
|
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
|
||||||
- {name: '3.6', python: '3.6', os: ubuntu-20.04, tox: py36} # ubuntu-latest doesn't support 3.6
|
|
||||||
- {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck}
|
- {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "docs/_themes"]
|
|
||||||
path = docs/_themes
|
|
||||||
url = https://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
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -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::
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = Flask-DebugToolbar
|
name = Flask-DebugToolbar
|
||||||
version = 0.14.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
|
||||||
@@ -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
|
||||||
|
|||||||
8
setup.py
8
setup.py
@@ -4,11 +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',
|
'MarkupSafe',
|
||||||
'packaging',
|
'packaging',
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"docs": [
|
||||||
|
'Sphinx>=1.2.2',
|
||||||
|
'Pallets-Sphinx-Themes',
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
|
import contextvars
|
||||||
import os
|
import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from packaging import version as version_builder
|
|
||||||
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
|
||||||
|
|
||||||
if version_builder.parse(flask.__version__) >= version_builder.parse("2.2.0"):
|
|
||||||
from flask.globals import request_ctx
|
|
||||||
else:
|
|
||||||
from flask.globals import _request_ctx_stack
|
|
||||||
|
|
||||||
|
|
||||||
from jinja2 import __version__ as __jinja_version__
|
from jinja2 import __version__ as __jinja_version__
|
||||||
from jinja2 import Environment, PackageLoader
|
from jinja2 import Environment, PackageLoader
|
||||||
@@ -64,7 +58,9 @@ class DebugToolbarExtension(object):
|
|||||||
|
|
||||||
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':
|
||||||
@@ -132,11 +128,7 @@ class DebugToolbarExtension(object):
|
|||||||
|
|
||||||
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."""
|
||||||
if version_builder.parse(flask.__version__) >= version_builder.parse("2.2.0"):
|
req = request_ctx.request
|
||||||
req = request_ctx.request
|
|
||||||
else:
|
|
||||||
req = _request_ctx_stack.top.request
|
|
||||||
|
|
||||||
app = current_app
|
app = current_app
|
||||||
|
|
||||||
if req.routing_exception is not None:
|
if req.routing_exception is not None:
|
||||||
@@ -178,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):
|
||||||
@@ -191,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
|
||||||
|
|
||||||
@@ -204,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
|
||||||
@@ -250,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)
|
||||||
@@ -267,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)
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -88,7 +92,14 @@ 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):
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ except ImportError:
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
from flask_sqlalchemy.record_queries import get_recorded_queries
|
from flask_sqlalchemy.record_queries import get_recorded_queries
|
||||||
|
debug_enables_record_queries = False
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# For flask_sqlalchemy < 3.0.0
|
# For flask_sqlalchemy < 3.0.0
|
||||||
from flask_sqlalchemy import get_debug_queries as get_recorded_queries
|
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'
|
location_property = 'context'
|
||||||
else:
|
else:
|
||||||
location_property = 'location'
|
location_property = 'location'
|
||||||
@@ -62,7 +67,10 @@ def extension_used():
|
|||||||
|
|
||||||
|
|
||||||
def recording_enabled():
|
def recording_enabled():
|
||||||
return (current_app.debug or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
|
return (
|
||||||
|
(debug_enables_record_queries and current_app.debug) or
|
||||||
|
current_app.config.get('SQLALCHEMY_RECORD_QUERIES')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_available():
|
def is_available():
|
||||||
|
|||||||
@@ -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,
|
|
||||||
})
|
})
|
||||||
|
|||||||
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;" role="navigation">
|
<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>
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -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'
|
|
||||||
|
|||||||
10
tox.ini
10
tox.ini
@@ -1,8 +1,8 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
py27
|
py3{12,11,10,9,8,7}
|
||||||
py3{12,11,10,9,8,7,6}
|
|
||||||
stylecheck
|
stylecheck
|
||||||
|
minimal
|
||||||
skip_missing_interpreters = True
|
skip_missing_interpreters = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@@ -13,6 +13,12 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
pytest
|
pytest
|
||||||
|
|
||||||
|
[testenv:minimal]
|
||||||
|
deps =
|
||||||
|
.
|
||||||
|
commands =
|
||||||
|
python -c "from flask_debugtoolbar import DebugToolbarExtension"
|
||||||
|
|
||||||
[testenv:stylecheck]
|
[testenv:stylecheck]
|
||||||
deps =
|
deps =
|
||||||
pycodestyle
|
pycodestyle
|
||||||
|
|||||||
Reference in New Issue
Block a user