summaryrefslogtreecommitdiff
path: root/paste/cgitb_catcher.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2006-10-20 18:29:53 +0000
committerianb <devnull@localhost>2006-10-20 18:29:53 +0000
commit6f36af9a6471d0461ab15ee9b23dbe7e1fe5730b (patch)
treecdaf4b3653771062ad70ee4b26ca031ac00a089d /paste/cgitb_catcher.py
parent54422a37644e55d264a3dc68da90287e3907a9b4 (diff)
downloadpaste-6f36af9a6471d0461ab15ee9b23dbe7e1fe5730b.tar.gz
Moved cgitb middleware entry point to separate function
Diffstat (limited to 'paste/cgitb_catcher.py')
-rw-r--r--paste/cgitb_catcher.py37
1 files changed, 34 insertions, 3 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)