Moya Debug

Moya Debug is a built in library that enables some debug only features. The primary feature is the error page that renders a Moya Traceback and error information.

Installation

Moya Debug is a built in library, and may be installed via its Python path as follows:

<import py="moya.libs.debug" if=".debug" priority="100"/>

The if=".debug" test ensures that Moya Debug is only imported when debug mode is enabled. Debug mode is enabled in settings as follows:

[project]
debug = yes

Your production.ini will set debug to no to disable Moya Debug in a production environment.

The priority="100" attribute ensures that templates in Moya Debug have the highest priority – in order to override any error handlers you have created.

You may install the library with the following line:

<install name="debug" lib="moya.debug" mount="/debug/" if=".debug" />

This mounts the debug views on /debug/ (if the server is running in debug mode).

Error Handlers

Moya Debug supplies handlers for 404 (not found) and 500 (internal error) pages by overriding the 404.html and 500.html templates respectively.

Not Found

The Not Found page will display information about the request, and the URL routes Moya ran through to attempt to generate a response. There are two possible scenarios that generate a 404 page; either there was no route matching the URL, or a route was found but your code intentionally returned a Not Found response. The Trace panel on the debug 404 page will tell you which was the case.

Internal Error

The Internal Error page will display information about the request, plus snapshot of the code being executed when the error occurred – which may be Moya code or template.

User Views

The url /debug/user/ whil show you information about the currently logged in user, including groups and permissions. You can also view the same information on other users by visiting /debug/user/<USERNAME/.

Code Introspection

Moya Debug can display the code for any element – with syntax highlighting. Clicking a element reference in the 404 page will link to the debug view that displays code. For example, /debug/element/moya.pages%23view.page/.

Moya Debug can also display templates from the template filesystem. For example /debug/templates/500.html would show you the template Moya Debug uses to render the Internal Error page.