From 2c19fc8827fa625ce247fee02ed6a2b8d08b772c Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Thu, 18 Aug 2005 21:54:46 +0000 Subject: Added parameter to force printing even when content-type isn't html --- paste/printdebug.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'paste/printdebug.py') 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): 'Log messages
' '%s') - 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()) -- cgit v1.2.1