diff options
| author | bwarsaw | 2002-10-01 23:04:30 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-10-01 23:04:30 +0000 |
| commit | 6114496ed6c8705875fb92c04d847a28071fa848 (patch) | |
| tree | 0c496fac9c8f77072a6526bc42187a262081b5e2 /scripts | |
| parent | a03d9917c5e801af6933345a9cbb807b0a4e4b8e (diff) | |
| download | mailman-6114496ed6c8705875fb92c04d847a28071fa848.tar.gz mailman-6114496ed6c8705875fb92c04d847a28071fa848.tar.zst mailman-6114496ed6c8705875fb92c04d847a28071fa848.zip | |
run_main(): When running the cgi, redirect stdout to a cStringIO, and
only if the cgi script runs to completion successfully do we write the
entire output to the real stdout (connected to the web server). This
way, if any exception occurs during the rendering of the page (e.g. in
"print doc.Format()") we won't mess up the diagnostics page.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/driver | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/driver b/scripts/driver index 0b6480c7f..60c8c79e1 100644 --- a/scripts/driver +++ b/scripts/driver @@ -66,6 +66,10 @@ def run_main(): manual_reprime=1, nofail=0, immediate=1) + # Collect stdout in a cStringIO so that if /any/ errors occur during + # printing it won't mess up our diagnostics page. + from cStringIO import StringIO + tempstdout = StringIO() # The name of the module to run is passed in argv[1]. What we # actually do is import the module named by argv[1] that lives in the # Mailman.Cgi package. That module must have a main() function, which @@ -79,9 +83,12 @@ def run_main(): try: try: sys.stderr = logger + sys.stdout = tempstdout main() + sys.__stdout__.write(tempstdout.getvalue()) finally: sys.stderr = sys.__stderr__ + sys.stdout = sys.__stdout__ except SystemExit: # This is a valid way for the function to exit. pass |
