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

David Zaslavsky diazona at gmail.com
Wed Mar 3 19:56:02 EST 2010

If I understand correctly: you're talking about a situation where the client 
visits the URL wifikeys.py/index, which generates the page that includes the 
HTML form; then the user fills in the form and submits it via POST method to 
the URL wifikeys.py/gen_keys, at which time mod_python calls the gen_keys 
method, right?

The normal way to pass data to a form handler (your gen_keys method) is to 
encode it as hidden input fields in the form.  For each pair "name"="value" 
that you want to transmit to gen_keys, the form should include an element like
 <input type="hidden" name="name" value="value">
These input elements will not show up in the browser but their names and 
values will be submitted along with the visible form fields, just like any 
other input elements in the form.  (Note that a technically savvy user can 
change the values)

Another way to handle it would be to store the data in a session.

:) David

On Wednesday 03 March 2010 6:28:07 am Rob Fowler wrote:
> Excuse me if this has been answered, I have searched for an answer but I
> am open to someone saying 'FAQ ask this'.
> I have a web form with this in it:
> ..
> <FORM value="form" action="wifikeys.py/gen_keys" method="post">
> ..
> the function 'gen_keys' needs a dictionary already read in the index
> function.
> Is there a normal way to get an objects from 'index' to 'gen_keys' (in
> other words from the initial python function to the function called by
> the post)?
>  From my understanding, apache calls the index function to get the data
> to populate the reply then the function yields back to apache, with
> nothing called until the client 'POSTS' then apache calls the post
> function specified.
> I use a database so I already solved the lack of database handle on the
> post method using a singleton and simply instancing it in the post
> function (globals by any other name) but this function needs different
> data depending on the form.
> TIA,
>   Rob Fowler
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20100303/7b8c88e9/attachment.bin

More information about the Mod_python mailing list