Debug Tools for py4web
Project description
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, fancy_rendering?: bool, bar_style?: "bootstrap", slow_threshold_ms?: int)
:
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.
enabled
can be used to dynamically turn on/off the debug features.
fancy_rendering
: This will render thedata
section 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.
bar_style
: only bootstrap is supported at this moment.
slow_threshold_ms
: amount of milliseconds an SQL query has to take before it is considered a 'slow query' in the debug bar.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_dict
and more. Seedumping.py:DDJsonEncoder
for specifics)dd(*)
: Show a page with the data passed to this method and halt execution directly.
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 {}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py4web-debug-tools-0.2.0.dev0.tar.gz
.
File metadata
- Download URL: py4web-debug-tools-0.2.0.dev0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af12be4de14af8d748dd2627d11df0c04c57b907153d4a48b605b224ffdf533 |
|
MD5 | 7de56e876f5d8b79ba6d87825becb8d8 |
|
BLAKE2b-256 | 32368fd025728ff39a1f8abcccf0e9afaecb8e728825ee8a1e836479a4aaa4c4 |
File details
Details for the file py4web_debug_tools-0.2.0.dev0-py3-none-any.whl
.
File metadata
- Download URL: py4web_debug_tools-0.2.0.dev0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f98495215e8802a3c37f5812e783f27d6a0c83ad7a8fdeace9af194edcfa4e |
|
MD5 | 3af5c6fb92768ef87e614f58e2b1f1fa |
|
BLAKE2b-256 | 0ee0a64e365aa55bcd7f7fd4ae51b8794b73fbc3f0eb3487d5a7db33c690ddb7 |