Adding documentation for the debug middleware, including docstrings.

This commit is contained in:
Jonathan LaCour
2012-03-23 15:04:26 -07:00
parent d222c453ec
commit ec257c2a93
6 changed files with 70 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -9,7 +9,37 @@ Reloading Automatically as Files Change
Debugging Pecan Applications
----------------------------
TODO
Pecan comes with a simple debugging middleware for helping track down problems
in your applications. To enable the debugging middleware, simply set the
``debug`` flag to ``True`` in your configuration file::
app = {
...
'debug': True,
...
}
Once enabled, the middleware will automatically catch exceptions raised by your
application, and display the Python stack trace and WSGI environment in your
browser for easy debugging.
.. figure:: debug-middleware-1.png
:alt: Pecan debug middleware sample output.
:width: 90%
:align: center
To further aid in debugging, the middleware includes the ability to repeat the
offending request, automatically inserting a breakpoint, and dropping your
console into the Python debugger, ``pdb``.
.. figure:: debug-middleware-2.png
:alt: Pecan debug middleware request debugger.
:align: center
For more information, refer to the
`documentation for pdb <http://docs.python.org/library/pdb.html>`_ available on
the Python website.
Serving Static Files
--------------------

View File

@@ -73,6 +73,7 @@ docstrings here:
pecan_decorators.rst
pecan_deploy.rst
pecan_hooks.rst
pecan_middleware_debug.rst
pecan_jsonify.rst
pecan_rest.rst
pecan_routing.rst

View File

@@ -0,0 +1,9 @@
.. _pecan_middleware_debug:
:mod:`pecan.middleware.debug` -- Pecan Debugging Middleware
===========================================================
.. automodule:: pecan.middleware.debug
:members:
:show-inheritance:

View File

@@ -231,6 +231,35 @@ class PdbMiddleware(object):
class DebugMiddleware(object):
"""A WSGI middleware that provides debugging assistance for development
environments.
To enable the debugging middleware, simply set the ``debug`` flag to
``True`` in your configuration file::
app = {
...
'debug': True,
...
}
Once enabled, the middleware will automatically catch exceptions raised by
your application, and display the Python stack trace and WSGI environment
in your browser for easy debugging.
To further aid in debugging, the middleware includes the ability to repeat
the offending request, automatically inserting a breakpoint, and dropping
your console into the Python debugger, ``pdb``.
For more information, refer to the `documentation for pdb
<http://docs.python.org/library/pdb.html>`_ available on the Python
website.
:param app: the application to wrap.
:param debugger: a callable to start debugging, defaulting to the Python
debugger, ``pdb``.
"""
def __init__(self, app, debugger=pdb.post_mortem):
self.app = app
self.debugger = debugger