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

Rob Fowler legal at mianos.com
Wed Mar 3 19:27:53 EST 2010


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. What I want to do is pass a parameter to the 'POST' function 
(gen_keys here).
For example, to change my example to the model suggested below:

def gen_keys(dictionary):
     do stuff

def handler(req):
     If req.method == "POST":
         gen_keys(specificDictionary )
     else:
         specificDictionary = readDictionary("/blah/specialdict.txt", 
"rule 1")
         req.write("""<HTML ... <FORM value="form" 
action="handler.py/handler" method="post"> etc
     return apache.OK

Just use global variables? I don't like to use them in apache modules, 
just the vibe.

On 4/03/2010 12:30 AM, Martijn Moeling wrote:
> I'm nut excacly sure what you are trying to achieve.
>
> In your index.py handler you can:
>
> from wifikeys import gen_keys
>
> def handler(req):
> 	If req.method == "POST":
> 		gen_keys(parameters here)
> 	else:
> 		normal handler code
> 	retrun apache.OK
>
>
>
> On Mar 3, 2010, at 12:28 PM, Rob Fowler wrote:
>
>    
>



More information about the Mod_python mailing list