how to modify text in html form from python

Philippe C. Martin pmartin at snakecard.com
Fri Oct 21 20:55:56 CEST 2005


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