summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Bicking <ian@ianbicking.org>2005-08-22 21:35:39 +0000
committerIan Bicking <ian@ianbicking.org>2005-08-22 21:35:39 +0000
commitf1000a791381086bb63274cad9e9eac2a39e336d (patch)
tree577d536c978582cc914a3030475040f55c8436cd
parent5430301738f4acd92e77a0f5a49ec9e7cdd97744 (diff)
downloadpaste-git-f1000a791381086bb63274cad9e9eac2a39e336d.tar.gz
Cleanup from the last delete
-rw-r--r--paste/__init__.py6
-rw-r--r--paste/cgitb_catcher.py62
-rw-r--r--paste/fixture.py7
-rw-r--r--paste/tests/conftest.py4
-rw-r--r--setup.py1
-rw-r--r--tests/conftest.py7
6 files changed, 45 insertions, 42 deletions
diff --git a/paste/__init__.py b/paste/__init__.py
index 5b85f25..792d600 100644
--- a/paste/__init__.py
+++ b/paste/__init__.py
@@ -1,5 +1 @@
-import pyconfig
-
-__all__ = ["CONFIG"]
-
-CONFIG = pyconfig.DispatchingConfig()
+#
diff --git a/paste/cgitb_catcher.py b/paste/cgitb_catcher.py
index b417583..a245299 100644
--- a/paste/cgitb_catcher.py
+++ b/paste/cgitb_catcher.py
@@ -9,48 +9,58 @@ documentation for more:
import cgitb
from cStringIO import StringIO
import sys
+from paste.deploy import converters
-class DummyFile(object):
+class NoDefault:
pass
-def middleware(application, **kw):
+class CgitbMiddleware(object):
- def start_application(environ, start_response):
- started = []
+ def __init__(self, app,
+ global_conf,
+ display=NoDefault,
+ logdir=None,
+ context=5,
+ format="html"):
+ self.app = application
+ if display is NoDefault:
+ display = global_conf.get('debug')
+ self.display = converters.asbool(display)
+ self.logdir = logdir
+ self.context = int(context)
+ self.format = format
- def detect_start_response(status, headers, exc_info=None):
- started.append(start_response(status, headers, exc_info))
- return started[0]
-
+ def __call__(self, environ, start_response):
try:
- app_iter = application(environ, detect_start_response)
+ app_iter = self.app(environ, start_response)
return catching_iter(app_iter)
except:
- if not started:
- write = start_response('500 Internal Server Error',
- [('content-type', 'text/html')])
- else:
- write = started[0]
- dummy_file = DummyFile()
- dummy_file.write = write
+ exc_info = sys.exc_info()
+ start_response('500 Internal Server Error',
+ [('content-type', 'text/html')],
+ exc_info)
dummy_file = StringIO()
- hook = cgitb.Hook(**kw)
- hook.file = dummy_file
- hook(*sys.exc_info())
+ hook = cgitb.Hook(file=dummy_file,
+ display=self.display,
+ logdir=self.logdir,
+ context=self.context,
+ format=self.format)
+ hook(*exc_info)
return [dummy_file.getvalue()]
- def catching_iter(app_iter):
+ def catching_iter(self, app_iter):
if not app_iter:
raise StopIteration
try:
for v in app_iter:
yield v
except:
- exc = sys.exc_info()
+ exc_info = sys.exc_info()
dummy_file = StringIO()
- hook = cgitb.Hook(**kw)
- hook.file = dummy_file
- hook(*exc)
+ hook = cgitb.Hook(file=dummy_file,
+ display=self.display,
+ logdir=self.logdir,
+ context=self.context,
+ format=self.format)
+ hook(*exc_info)
yield dummy_file.getvalue()
-
- return start_application
diff --git a/paste/fixture.py b/paste/fixture.py
index abf2e91..18f20d6 100644
--- a/paste/fixture.py
+++ b/paste/fixture.py
@@ -20,9 +20,6 @@ else:
import doctest
from paste import wsgilib
from paste import lint
-from paste import pyconfig
-from paste import CONFIG
-from paste import server
def tempnam_no_warning(*args):
"""
@@ -492,10 +489,6 @@ def setup_module(module=None):
This is used by py.test if it is in the module, so do::
from paste.tests.fixture import setup_module
-
- to enable this. This adds an ``app`` and ``CONFIG`` object to the
- module. If there is a function ``reset_state`` in your module
- then that is also called.
"""
if module is None:
# The module we were called from must be the module...
diff --git a/paste/tests/conftest.py b/paste/tests/conftest.py
deleted file mode 100644
index 93bca7d..0000000
--- a/paste/tests/conftest.py
+++ /dev/null
@@ -1,4 +0,0 @@
-import sys
-import os
-
-sys.insert(0, os.path.dirname(os.path.dirname(__file__)))
diff --git a/setup.py b/setup.py
index 5467cbd..1c6b178 100644
--- a/setup.py
+++ b/setup.py
@@ -54,6 +54,7 @@ functionality.
""",
'paste.filter_app_factory1': """
error_catcher=paste.exceptions.errormiddleware:ErrorMiddleware
+ cgitb=paste.cgitb_catcher:CgitbMiddleware
""",
},
)
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..0ee5ac0
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,7 @@
+import sys
+import os
+import pkg_resources
+
+pkg_resources.require('PasteDeploy')
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))