diff options
| author | ianb <devnull@localhost> | 2006-01-26 18:04:35 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2006-01-26 18:04:35 +0000 |
| commit | 8bfe1afc7c5a7ab80f722ada73019424a4b63819 (patch) | |
| tree | cf8f1c1a462988d4d96687bcb5f2c419197e33b5 /paste/debug | |
| parent | 2ea99159dffa41685396647367a4980868ecd3c5 (diff) | |
| download | paste-8bfe1afc7c5a7ab80f722ada73019424a4b63819.tar.gz | |
Allow printdebug to be suppressed dynamically
Diffstat (limited to 'paste/debug')
| -rw-r--r-- | paste/debug/prints.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/paste/debug/prints.py b/paste/debug/prints.py index 15d5963..f69b95a 100644 --- a/paste/debug/prints.py +++ b/paste/debug/prints.py @@ -59,6 +59,10 @@ class PrintDebugMiddleware(object): # @@: Not strictly threadsafe _threadedprint_installed = True threadedprint.install(leave_stdout=True) + removed = [] + def remove_printdebug(): + removed.append(None) + environ['paste.remove_printdebug'] = remove_printdebug logged = StringIO() if self.print_wsgi_errors: replacement_stdout = TeeFile(environ['wsgi.errors'], logged) @@ -77,9 +81,10 @@ class PrintDebugMiddleware(object): if not body: body = 'An error occurred' content_type = response.header_value(headers, 'content-type') - if (not self.force_content_type and - (not content_type - or not content_type.startswith('text/html'))): + if (removed or + (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()) |
