[mod_python] apache.OK and Cookies

Graham Dumpleton grahamd at dscpl.com.au
Mon May 22 18:48:38 EDT 2006


David Bear wrote ..
> On Tue, May 23, 2006 at 06:30:42AM +1000, Graham Dumpleton wrote:
> > 
> > On 23/05/2006, at 6:10 AM, David Bear wrote:
> > 
> > >On Sun, May 21, 2006 at 06:49:30PM -0400, Graham Dumpleton wrote:
> > >>Graham Dumpleton wrote ..
> > >>Thus, thus make sure you indicate what handler you are using as  
> > >>well as
> > >>the version of mod_python.
> > >
> > >this caused me to think, what happens when a publisher script returns
> > >a psp file? using the example from the mod_python.org web site, all
> > >the functions that are used to 'dispatch' different pages return the
> > >psp file. Does that implicitly then return apache.OK to apache? or is
> > >there something else that need to be done to keep apache happy?
> > 
> > The returned PSP object has a __str__() method so the PSP page gets
> > executed and string result sent in response.
> 
> so, the fact that at string  is being returned implies an apache.OK

Please try and keep followups on mailing list.

Anything returned using "return" from a publisher, or even implicit
return of "None", implies apache.OK. If you want to return some other
status you have to do one of either two things.

1. Raise an apache.SERVER_RETURN exception with status as argument.

  raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN

OR 2. Set status in req object explicitly.

  req.status = apache.HTTP_FORBIDDEN
  return "... page content ..."

When the result returned isn't a string or Unicode, publisher will apply str()
to it to convert it to a string representation. In the case of Unicode it will
convert it to a string based on calculated encoding type.

Graham


More information about the Mod_python mailing list