Skip to main content

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.

  1. A better error 500 screen, that shows the error + traceback of what happened
  2. A debug bar containing the requests's data, queries including duplicate and custom caught data.

In this package:

  • tools:
    • enable(db: DAL, enabled: 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.
    • debug_bar: this Fixture can be used on py4web actions to enable the bar for that page.
  • catch(*): Data and a stacktrace of where catch() 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 of as_dict and more. See dumping.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py4web-debug-tools-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

py4web_debug_tools-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file py4web-debug-tools-0.1.0.tar.gz.

File metadata

  • Download URL: py4web-debug-tools-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for py4web-debug-tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15a936e63e79045a2a2a5f21f25c8ddbd64cf32e15284cd4f650d117f3c30d76
MD5 4ca0e7d4af0218305dc98a6acc8cd515
BLAKE2b-256 738b9b471174a9541495b666d2cbe11924d6f9215254d287b2bb0e7381f0f516

See more details on using hashes here.

File details

Details for the file py4web_debug_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py4web_debug_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c18392b491213e9073df2fb96845a3f4c10b19adcd183ccc7257c564ea0be0a
MD5 cb5cff035881808896fccb23fb2c7c5d
BLAKE2b-256 dec363cc53ac95623e0cce111a7fb98e39bd80a01569db0d79560e97320e1a1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page