Re: passing parameters from index() to POST method

David Zaslavsky <[email protected]> Wed, 3 Mar 2010 19:56:02 -0500
Newsgroups gmane.comp.python.mod_python
Message-ID <[email protected]>
--===============2116555587==
Content-Type: multipart/signed; boundary="nextPart4514137.5Wqylz1fRg";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart4514137.5Wqylz1fRg
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: quoted-printable

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

The normal way to pass data to a form handler (your gen_keys method) is to=
=20
encode it as hidden input fields in the form.  For each pair "name"=3D"valu=
e"=20
that you want to transmit to gen_keys, the form should include an element l=
ike
 <input type=3D"hidden" name=3D"name" value=3D"value">
These input elements will not show up in the browser but their names and=20
values will be submitted along with the visible form fields, just like any=
=20
other input elements in the form.  (Note that a technically savvy user can=
=20
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=3D"form" action=3D"wifikeys.py/gen_keys" method=3D"post">
> ..
> the function 'gen_keys' needs a dictionary already read in the index
> function.
>=20
> 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)?
>=20
>  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.
>=20
> 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.
>=20
> TIA,
>   Rob Fowler
> _______________________________________________
> Mod_python mailing list
> [email protected]
> http://mailman.modpython.org/mailman/listinfo/mod_python

--nextPart4514137.5Wqylz1fRg
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEABECAAYFAkuPBSYACgkQFmx38lx22rKZlwCfY3fp+vvHeD4e67GZB4xuk+6b
Z50AoKIVLDEA/9ptatbs96FGCQZa77vK
=Qhl2
-----END PGP SIGNATURE-----

--nextPart4514137.5Wqylz1fRg--

--===============2116555587==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Mod_python mailing list
[email protected]
http://mailman.modpython.org/mailman/listinfo/mod_python

--===============2116555587==--