diff options
| author | ianb <devnull@localhost> | 2006-10-20 18:29:53 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2006-10-20 18:29:53 +0000 |
| commit | 6f36af9a6471d0461ab15ee9b23dbe7e1fe5730b (patch) | |
| tree | cdaf4b3653771062ad70ee4b26ca031ac00a089d | |
| parent | 54422a37644e55d264a3dc68da90287e3907a9b4 (diff) | |
| download | paste-6f36af9a6471d0461ab15ee9b23dbe7e1fe5730b.tar.gz | |
Moved cgitb middleware entry point to separate function
| -rw-r--r-- | paste/cgitb_catcher.py | 37 | ||||
| -rw-r--r-- | setup.py | 2 |
2 files changed, 35 insertions, 4 deletions
diff --git a/paste/cgitb_catcher.py b/paste/cgitb_catcher.py index 9492498..09d7b49 100644 --- a/paste/cgitb_catcher.py +++ b/paste/cgitb_catcher.py @@ -21,14 +21,14 @@ class NoDefault: class CgitbMiddleware(object): def __init__(self, app, - global_conf, + global_conf=None, display=NoDefault, logdir=None, context=5, format="html"): - # @@: global_conf should only be present in a seperate - # function for the entry point self.app = app + if global_conf is None: + global_conf = {} if display is NoDefault: display = global_conf.get('debug') if isinstance(display, basestring): @@ -83,3 +83,34 @@ class CgitbMiddleware(object): hook(*exc_info) return dummy_file.getvalue() +def make_cgitb_middleware(self, app, global_conf, + display=NoDefault, + logdir=None, + context=5, + format='html'): + """ + Wraps the application in the ``cgitb`` (standard library) + error catcher. + + display: + If true (or debug is set in the global configuration) + then the traceback will be displayed in the browser + + logdir: + Writes logs of all errors in that directory + + context: + Number of lines of context to show around each line of + source code + """ + from paste.deploy.converters import asbool + if display is not NoDefault: + display = asbool(display) + if 'debug' in global_conf: + global_conf['debug'] = asbool(global_conf['debug']) + return CgitbMiddleware( + app, global_conf=global_conf, + display=display, + logdir=logdir, + context=context, + format=format) @@ -154,7 +154,7 @@ For the latest changes see the `news file [paste.filter_app_factory] error_catcher = paste.exceptions.errormiddleware:make_error_middleware - cgitb = paste.cgitb_catcher:CgitbMiddleware + cgitb = paste.cgitb_catcher:make_cgitb_middleware flup_session = paste.flup_session:SessionMiddleware [Flup] gzip = paste.gzipper:middleware httpexceptions = paste.httpexceptions:make_middleware |
