Adding a debug middleware, which simply shows the traceback and dumps

the WSGI environment. No fancy inline debugging. Use pdb.
This commit is contained in:
Jonathan LaCour
2012-03-15 13:05:25 -07:00
parent a27c4ba94f
commit 638cd6cf02
2 changed files with 168 additions and 11 deletions

View File

@@ -1,7 +1,5 @@
from paste.errordocument import make_errordocument
from paste.translogger import TransLogger
from weberror.errormiddleware import ErrorMiddleware
from weberror.evalexception import EvalException
from core import (
abort, override_template, Pecan, load_app, redirect, render,
@@ -10,8 +8,8 @@ from core import (
from recursive import RecursiveMiddleware
from decorators import expose
from hooks import RequestViewerHook
from templating import error_formatters
from static import SharedDataMiddleware
from debug import DebugMiddleware
from configuration import set_config
from configuration import _runtime_conf as conf
@@ -35,27 +33,28 @@ def make_app(root, static_root=None, debug=False, errorcfg={},
# Instantiate the WSGI app by passing **kw onward
app = Pecan(root, **kw)
# Optionally wrap the app in another WSGI app
if wrap_app:
app = wrap_app(app)
# Included for internal redirect support
app = RecursiveMiddleware(app)
# Support for interactive debugging (and error reporting)
# When in debug mode, load our exception dumping middleware
if debug:
app = EvalException(
app,
templating_formatters=error_formatters,
**errorcfg
)
else:
app = ErrorMiddleware(app, **errorcfg)
app = DebugMiddleware(app)
# Configuration for serving custom error messages
if hasattr(conf.app, 'errors'):
app = make_errordocument(app, conf, **dict(conf.app.errors))
# Support for serving static files (for development convenience)
if static_root:
app = SharedDataMiddleware(app, static_root)
# Support for simple Apache-style logs
if isinstance(logging, dict) or logging == True:
app = TransLogger(app, **(isinstance(logging, dict) and logging or {}))
return app

158
pecan/debug.py Normal file

File diff suppressed because one or more lines are too long