don't give 500 for mere stdout on a redirect
authorGreg Price <price@mit.edu>
Mon, 21 Jul 2008 19:46:05 +0000 (15:46 -0400)
committerGreg Price <price@mit.edu>
Mon, 21 Jul 2008 19:46:05 +0000 (15:46 -0400)
svn path=/trunk/packages/sipb-xen-www/; revision=693

code/main.py

index 24254c7..f13fe0c 100755 (executable)
@@ -696,14 +696,12 @@ class App:
                 headers.update(new_headers)
             e = revertStandardError()
             if e:
                 headers.update(new_headers)
             e = revertStandardError()
             if e:
-                if isinstance(output, basestring):
-                    sys.stderr = StringIO()
-                    x = str(output)
-                    print >> sys.stderr, x
-                    print >> sys.stderr, 'XXX'
-                    print >> sys.stderr, e
-                    raise Exception()
-                output.addError(e)
+                if hasattr(output, 'addError'):
+                    output.addError(e)
+                else:
+                    # This only happens on redirects, so it'd be a pain to get
+                    # the message to the user.  Maybe in the response is useful.
+                    output = output + '\n\nstderr:\n' + e
             output_string =  str(output)
             checkpoint.checkpoint('output as a string')
         except Exception, err:
             output_string =  str(output)
             checkpoint.checkpoint('output as a string')
         except Exception, err: