[mod_python] passing parameters from index() to POST method

Martijn Moeling martijn at xs4us.nu
Thu Mar 4 04:58:12 EST 2010


I agree with both David and Graham,

Favicon.ico confuses a lot of people and setting HIDDEN PARAMETERS to the form might be a good solution. Indeed global variables are not the way to go since it will go horribly wrong when multiple users are using it, and with a reload (depending on your apache config/multiple processes/maxrequests etc. globals are not set correctly if the post is handled by a different process than the process serving the get of the form)

another small tip is to look at your apache access_log and error_log.

I have never ever seen requests come in twice, and I do a lot of low level HTTP stuff in my work (like building webdav, caldav servers etc.) . Dump your code and the Apache config together with  your access_log and error_log (clear them, and make one request and post)
so we can see what is really going on.

Martijn

On Mar 4, 2010, at 1:47 AM, Rob Fowler wrote:

> From my earlier example, it was not called twice. I made it called twice as suggested here.
> Maybe this is more clear: Ideally I simply want to have an index function to set the stuff up and show the form and another function that gets called when the client does the post (the easy bit) but I want some variables that are set up in the index to be present in the function called on post. Is there a standard way to post variable between the handler and the post functions?
> 
> 
> On 4/03/2010 11:41 AM, Graham Dumpleton wrote:
>> On 4 March 2010 11:27, Rob Fowler<legal at mianos.com>  wrote:
>>   
>>> Although that works fine and will call my post function, the apache server
>>> calls the handler a second time so all the local variables are new.
>>>     
>> You better explain that a bit better. The handler function should not
>> be called multiple times for the same request.
>> 
>> Dump out req.uri to see what URL is being accessed on each call. They
>> may actually be two separate requests. This can occur where a web
>> browser keeps requesting a favicon.ico and it doesn't exist.
>> 
>> Graham
>> 
>>   
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python




More information about the Mod_python mailing list