[mod_python] apache.OK and Cookies

Graham Dumpleton grahamd at dscpl.com.au
Mon May 22 16:30:42 EDT 2006


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 ..
>>> jaba at findyourcore.com wrote ..
>>>> I have two questions:
>>>> 1. is 'return apache.OK' really needed? ive gone without it many  
>>>> times,
>>>> and nothing goes wrong.
>>>
>>> What version of mod_python are you using?
>>>
>>> Can you clarify whether you are using your own handler, where it  
>>> would
>>> should be used, or whether you are using mod_python.publisher  
>>> where it
>>> would not, but if it was may simply result in a extraneous "0" at  
>>> end of
>>> output that may get overlooked.
>>>
>>> In summary, if using your own handler, you should always return  
>>> it. If
>>> you don't, you should at least see a warning message in the  
>>> Apache log
>>> files and the results may be unpredictable as to how Apache  
>>> treats the
>>> result.
>>
>> Actually, as well as the error in the log file, mod_python should  
>> end up
>> sending an internal server error (500) response back to Apache. If  
>> you
>> aren't seeing this, then I would suspect you aren't writing your own
>> handler and are using some layer on top where the result may not  
>> even be
>> a status code, or where status codes are treated differently. For
>> example, in mod_python.publisher, the result is converted to a string
>> and append to the content. In Vampire, if nothing is returning it is
>> equivalent to having returned apache.OK.
>>
>> 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.

Graham


More information about the Mod_python mailing list