Had a problem in my Turbogears app in that I was trying to set a cookie. It worked nicely under development, running on the cherrypy server but it didn't work in production when running under mod_python/apache. Eventually I established that it was because my http response was trying to send two cookies (my cookie and the session cookie) and only the last one was actually being sent to the browser.
I pinned it down to the mpcp script that I am using to interface mod_python with cherrypy. It has this code:
elif tv is str: req.headers_out[header] = value
which is only allowing one 'Set-Cookie' header to be defined, later ones will overwrite the original.
Changing the code to the following fixes the problem:
elif tv is str: if header.lower() != 'set-cookie': req.headers_out[header] = value else: req.headers_out.add( 'Set-Cookie', value)

