{"id":23734024,"url":"https://github.com/trialandsuccess/py4web-debug-tools","last_synced_at":"2025-09-14T15:17:36.398Z","repository":{"id":70930306,"uuid":"604589220","full_name":"trialandsuccess/py4web-debug-tools","owner":"trialandsuccess","description":"Tooling to improve the developer experience when working with py4web","archived":false,"fork":false,"pushed_at":"2025-04-01T10:48:40.000Z","size":106,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-04T09:51:14.542Z","etag":null,"topics":["py4web","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/py4web-debug-tools/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trialandsuccess.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-21T11:33:53.000Z","updated_at":"2025-04-01T10:48:43.000Z","dependencies_parsed_at":"2025-09-04T09:43:29.336Z","dependency_job_id":null,"html_url":"https://github.com/trialandsuccess/py4web-debug-tools","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/trialandsuccess/py4web-debug-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trialandsuccess%2Fpy4web-debug-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trialandsuccess%2Fpy4web-debug-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trialandsuccess%2Fpy4web-debug-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trialandsuccess%2Fpy4web-debug-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trialandsuccess","download_url":"https://codeload.github.com/trialandsuccess/py4web-debug-tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trialandsuccess%2Fpy4web-debug-tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275122496,"owners_count":25409249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["py4web","python"],"created_at":"2024-12-31T05:33:17.166Z","updated_at":"2025-09-14T15:17:36.389Z","avatar_url":"https://github.com/trialandsuccess.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py4web debug tools\n\nTooling to improve the developer experience when working with py4web.\n\nThere are two main tools and some helpers that this package provides.\n\n1. A better error 500 screen, that shows the error + traceback of what happened\n2. A debug bar containing the requests's data, queries including duplicate and custom caught data.\n\n## In this package:\n\n- `tools`:\n    - `enable(db: DAL, enabled?: bool,\nerrorpage_enabled?: bool,\nerrorpage_renderer?: Callable,\ndebugbar_enabled?: bool,\ndebugbar_fancy_rendering?: bool,\ndebugbar_style?: \"bootstrap\",\ndebugbar_slow_threshold_ms?: int,\nset_env_var?: bool)`:  \n      activate or disable the debug tools (add the custom error screen and create the Debug Bar Fixture).  \n      The first argument (DAL) is required for the debug bar to collect queries.  \n      `enabled` can be used to dynamically turn on/off the debug features.  \n      `errorpage_enabled` and `debugbar_enabled` can be used to turn on/off the error page and debug bar respectively.  \n      `errorpage_renderer` can be used to override the default error page renderer.   \n      `debugbar_fancy_rendering`: This will render the `data` section of the debug bar using `json-browse`, which\n      includes `jQuery`. If this clashes with the other JS on a page, this can be set to False to simply show a `\u003cpre\u003e`\n      block with data.  \n      `debugbar_style`: only bootstrap is supported at this moment.  \n      `debugbar_slow_threshold_ms`: amount of milliseconds an SQL query has to take before it is considered a 'slow query' in the\n      debug bar.  \n      `set_env_var`: set the `PY4WEB_DEBUG` environment variable to `True` when enabling the debug tools.\n    - `debug_bar`: this Fixture can be used on py4web actions to enable the bar for that page.\n- `catch(*)`: Data and a stacktrace of where `catch()` is called can be found in the catch tab of the debug bar.\n- `dump(*)`: convert objects to JSON, with a more capable converter than the default json.dumps (e.g. it works better\n  with NamedTuples, pyDAL Rows, objects with some variation of `as_dict` and more. See `dumping.py:DDJsonEncoder` for\n  specifics)\n- `dd(*)`: Show a page with the data passed to this method and halt execution directly.\n- `wsgi`: a patched version of py4web's `wsgi` module, that will enable the modified error page.\n\n## Example:\n\n```python\n# controllers.py\n\nfrom py4web_debug import tools, catch, dump, dd\n\ntools.enable(db, enabled=True)\n\n\n@action(\"index\")\n@action.uses(\"index.html\", db, tools.debug_bar)\ndef index():\n    catch(\"Catch to Debug Bar\")\n    return {}\n\n\n@action(\"other\")\n@action.uses(\"index.html\", db)\ndef page_without_debugbar():\n    dd(\"Stop executing here!\")\n    return {}\n\n\n@action(\"error\")\n@action.uses(\"index.html\", db)\ndef page_with_error():\n    0 / 0\n    return {}\n```\n\n## Caveats:\n\nWhen using uwsgi, the default method (in `__init__`) of changing py4web's `catch_errors` will not work.\nThis is because the routes are set up before this package can be enabled.\nYou can modify your `py4web_uwsgi.py` file:\n\n```python\n# no: from py4web.core import wsgi\n# yes:\nfrom py4web_debug import wsgi\n\napplication = wsgi(apps_folder=\"apps\",\n                   password_file='password.txt',\n                   dashboard_mode=\"full\")\n```\n\nAfter this, you can `tools.enable` as before.\nDo note this process will keep py4web patched though, even when `enable(enabled=False)` is passed!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialandsuccess%2Fpy4web-debug-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrialandsuccess%2Fpy4web-debug-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialandsuccess%2Fpy4web-debug-tools/lists"}