how to modify text in html form from python

Philippe C. Martin pmartin at snakecard.com
Fri Oct 21 15:18:40 EDT 2005


PS: If my question is not clear, I am trying to "share" the form between the
client and server.

just as many sites out there allow you to modify existing data:
1) the server pops up a form with your data in it.
2) the client can modify it and submit.

I know this is a _basic_ question, sorry.

Philippe



Philippe C. Martin wrote:

> Hi,
> 
> I am trying to change the data in a form field from python. The following
> code does not crash but has no effect as if "form" is just a copy of the
> original html form.
> 
> Must I recreate the form order to do that ?
> 
> My point is for the client to be able to re-read the modified data.
> 
> 
> Thanks,
> 
> Philippe
> #!/usr/bin/python
> 
> import cgi
> import os
> import sys
> import logging
> import cgi
> sys.stderr = sys.stdout
> print "Content-type: text/html\n"
> try:
>     form = cgi.FieldStorage()
>     #logging.warning (form)
>     
> except:
>     logging.exception("\nEXCEPTION 1")
> try:
> 
>     form['tosrv'].value = "TEST"
> except:
>     logging.exception("\nEXCEPTION 2")
>     pass
> 
>     <html>
>     <body>
>     <title>Smart Logon</title>
>     <h1>Smart Logon</h1>
>     <hr>
>     <FORM METHOD=POST ACTION="/cgi-bin/scfbweb.py">
>     <table>
>     <TR><TD>
>       <INPUT TYPE=HIDDEN NAME="key" VALUE="process">
>      TO SERVER:<BR>
>       <INPUT  type=text NAME="tosrv" value="TO" size=60>
>       <BR>
>       FROM SERVER<BR>
>       <INPUT type=text name="fromsrv" value="FROM" size=60>
>       <P>
>         <INPUT TYPE="SUBMIT" VALUE="START">
> 
>     </TD></TR></table>
>         </FORM>
> </body>
> </html>




More information about the Python-list mailing list