diff options
author | Ian Bicking <ian@ianbicking.org> | 2005-08-18 21:54:46 +0000 |
---|---|---|
committer | Ian Bicking <ian@ianbicking.org> | 2005-08-18 21:54:46 +0000 |
commit | 2c19fc8827fa625ce247fee02ed6a2b8d08b772c (patch) | |
tree | c22992c7c68ec717200c56ef2fbdf03b6be785d4 | |
parent | 3bdefeaf8a340e5a57250f5689cebc901524eecb (diff) | |
download | paste-git-2c19fc8827fa625ce247fee02ed6a2b8d08b772c.tar.gz |
Added parameter to force printing even when content-type isn't html
-rw-r--r-- | paste/printdebug.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/paste/printdebug.py b/paste/printdebug.py index 56ac28e..83250ab 100644 --- a/paste/printdebug.py +++ b/paste/printdebug.py @@ -37,8 +37,9 @@ class PrintDebugMiddleware(object): '<b style="border-bottom: 1px solid #000">Log messages</b><br>' '%s</pre>') - def __init__(self, subapp): + def __init__(self, subapp, force_content_type=False): self.subapp = subapp + self.force_content_type = force_content_type def __call__(self, environ, start_response): global _threadedprint_installed @@ -65,7 +66,9 @@ class PrintDebugMiddleware(object): if not body: body = 'An error occurred' content_type = wsgilib.header_value(headers, 'content-type') - if not content_type or not content_type.startswith('text/html'): + if (not self.force_content_type and + (not content_type + or not content_type.startswith('text/html'))): if replacement_stdout == logged: # Then the prints will be lost, unless... environ['wsgi.errors'].write(logged.getvalue()) |