py4web debug tools
Tooling to improve the developer experience when working with py4web.
There are two main tools and some helpers that this package provides.
- A better error 500 screen, that shows the error + traceback of what happened
- A debug bar containing the requests's data, queries including duplicate and custom caught data.
In this package:
tools:enable(db: DAL, enabled?: bool, errorpage_enabled?: bool, errorpage_renderer?: Callable, debugbar_enabled?: bool, debugbar_fancy_rendering?: bool, debugbar_style?: "bootstrap", debugbar_slow_threshold_ms?: int, set_env_var?: bool):
activate or disable the debug tools (add the custom error screen and create the Debug Bar Fixture).
The first argument (DAL) is required for the debug bar to collect queries.
enabledcan be used to dynamically turn on/off the debug features.
errorpage_enabledanddebugbar_enabledcan be used to turn on/off the error page and debug bar respectively.
errorpage_renderercan be used to override the default error page renderer.
debugbar_fancy_rendering: This will render thedatasection of the debug bar usingjson-browse, which includesjQuery. If this clashes with the other JS on a page, this can be set to False to simply show a<pre>block with data.
debugbar_style: only bootstrap is supported at this moment.
debugbar_slow_threshold_ms: amount of milliseconds an SQL query has to take before it is considered a 'slow query' in the debug bar.
set_env_var: set thePY4WEB_DEBUGenvironment variable toTruewhen enabling the debug tools.debug_bar: this Fixture can be used on py4web actions to enable the bar for that page.
catch(*): Data and a stacktrace of wherecatch()is called can be found in the catch tab of the debug bar.dump(*): convert objects to JSON, with a more capable converter than the default json.dumps (e.g. it works better with NamedTuples, pyDAL Rows, objects with some variation ofas_dictand more. Seedumping.py:DDJsonEncoderfor specifics)dd(*): Show a page with the data passed to this method and halt execution directly.wsgi: a patched version of py4web'swsgimodule, that will enable the modified error page.
Example:
# controllers.py
from py4web_debug import tools, catch, dump, dd
tools.enable(db, enabled=True)
@action("index")
@action.uses("index.html", db, tools.debug_bar)
def index():
catch("Catch to Debug Bar")
return {}
@action("other")
@action.uses("index.html", db)
def page_without_debugbar():
dd("Stop executing here!")
return {}
@action("error")
@action.uses("index.html", db)
def page_with_error():
0 / 0
return {}
Caveats:
When using uwsgi, the default method (in __init__) of changing py4web's catch_errors will not work.
This is because the routes are set up before this package can be enabled.
You can modify your py4web_uwsgi.py file:
# no: from py4web.core import wsgi
# yes:
from py4web_debug import wsgi
application = wsgi(apps_folder="apps", password_file="password.txt", dashboard_mode="full")
After this, you can tools.enable as before.
Do note this process will keep py4web patched though, even when enable(enabled=False) is passed!
Metadata
Release files for py4web-debug-tools 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py4web_debug_tools-1.4.0.tar.gz | 15.1 kB | Without provenance | Details for py4web_debug_tools-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py4web_debug_tools-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for py4web_debug_tools-1.4.0-py3-none-any.whl |
Total release size: 32.8 kB
Release files / py4web_debug_tools-1.4.0.tar.gz
| Download URL | py4web_debug_tools-1.4.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a27350eb67581bc8fc58fecdf1cb5ab45d2d18f223717aa84bdc863ab69ea78d
|
|
BLAKE2b-256 checksum How to use checksums |
7b5cd726002e5ec01664c934f722704129786b8eefdf2fdb097bdcddcb7c7d3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / py4web_debug_tools-1.4.0-py3-none-any.whl
| Download URL | py4web_debug_tools-1.4.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a06b16e558653179796efdb8632f6733c680d0c83434cfb7075bc7f28e166493
|
|
BLAKE2b-256 checksum How to use checksums |
6fe3cb14ab350ae0b1c21a21b0f909047ea41c3b047affee9ecdc3e4314b496e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for py4web-debug-tools 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.