diff options
| author | Ian Bicking <ian@ianbicking.org> | 2006-01-26 18:04:35 +0000 |
|---|---|---|
| committer | Ian Bicking <ian@ianbicking.org> | 2006-01-26 18:04:35 +0000 |
| commit | 85b1fa7763ed92c0ae70bf77d6d17d2e0f244571 (patch) | |
| tree | cf8f1c1a462988d4d96687bcb5f2c419197e33b5 /paste/debug | |
| parent | c5c8a720d51a364c401567a73fc2a80344de04ed (diff) | |
| download | paste-git-85b1fa7763ed92c0ae70bf77d6d17d2e0f244571.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()) |
