summaryrefslogtreecommitdiff
path: root/paste/cascade.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-12-13 22:49:51 +0000
committerianb <devnull@localhost>2005-12-13 22:49:51 +0000
commit19657d6165b94d9e1a006d3ad103f24426aa1631 (patch)
tree43d61fff7b042caea5b18523fc61026968faabb0 /paste/cascade.py
parent431acd0a6e9d98d370eb49ff83deb2d795290c31 (diff)
downloadpaste-19657d6165b94d9e1a006d3ad103f24426aa1631.tar.gz
Avoid using exceptions in Cascade; this was causing a problem if an exception-catching middleware was above the cascade process. Now it doesn't use exceptions at all.
Diffstat (limited to 'paste/cascade.py')
-rw-r--r--paste/cascade.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/paste/cascade.py b/paste/cascade.py
index cb581b2..7c07b80 100644
--- a/paste/cascade.py
+++ b/paste/cascade.py
@@ -66,16 +66,30 @@ class Cascade(object):
self.catch_exceptions = tuple(self.catch_exceptions)
def __call__(self, environ, start_response):
+ failed = []
def repl_start_response(status, headers, exc_info=None):
code = int(status.split(None, 1)[0])
if code in self.catch_codes:
- raise self.catch_codes[code]
+ failed.append(None)
+ return _consuming_writer
return start_response(status, headers, exc_info)
for app in self.apps[:-1]:
environ_copy = environ.copy()
+ failed = []
try:
- return app(environ_copy, repl_start_response)
- except self.catch_exceptions:
+ v = app(environ_copy, repl_start_response)
+ if not failed:
+ return v
+ else:
+ if hasattr(v, 'close'):
+ # Exhaust the iterator first:
+ list(v)
+ # then close:
+ v.close()
+ except self.catch_exceptions, e:
pass
return self.apps[-1](environ, start_response)
+
+def _consuming_writer(s):
+ pass