Special treatment for HTTP responses (was: Re: [Zope] adventure: return tuples from python scripts)

Dieter Maurer dieter@handshake.de
Fri, 19 Apr 2002 20:13:28 +0200


H.de.Wit@SFK.NL writes:
 > We tried to return a tuple from a function and had strange results
 > The following advanced python-scripts (the scripts are inside the quotes)
 > "return (1,2)" , "return 1,2", "return tuple((1,2))"
 > 
 > all return only 2
No, they return the correct tuple.

However, "ZPublisher.HTTPResponse.setBody" does special things with some
special return values. Most prominently:

  *  an Python false value is translated into an empty
     response. This leads many browsers to wait forever...

  *  a pair is interpreted as "title,body".

     That's your case. When you look at the HTML source, you
     will see your first element wrapped in a <title> and
     your second element in a <body> tag.


Dieter