how to modify text in html form from python
mwm at mired.org
Fri Oct 21 21:34:35 CEST 2005
"Philippe C. Martin" <pmartin at snakecard.com> writes:
> PS: If my question is not clear, I am trying to "share" the form between the
> client and server.
Yes, your question is not clear. And this statement doesn't clarify
it. That you quoted the "share" shows you are probably aware of this,
if not consciously so.
> 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.
This doesn't really help, either. The server can't "pop up" a form;
only the client can do that. All the server can do is send data to
The client can't modify data on the server. It can send data to the
server, but that arrives as *new* data. The server can use that to
replace old data, thus modifying that old data.
> I know this is a _basic_ question, sorry.
It's not clear it's a basic question, because it's not clear what
you're trying to do.
Try answering these questions:
Where do you expect the HTML to come from?
Where do you expect the data originally in the HTML form to come from?
Where do you expect the data the user inputs into the form to be stored?
> Philippe C. Martin wrote:
>> 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.
>> import cgi
>> import os
>> import sys
>> import logging
>> import cgi
>> sys.stderr = sys.stdout
>> print "Content-type: text/html\n"
>> form = cgi.FieldStorage()
>> #logging.warning (form)
>> logging.exception("\nEXCEPTION 1")
>> form['tosrv'].value = "TEST"
>> logging.exception("\nEXCEPTION 2")
>> <title>Smart Logon</title>
>> <h1>Smart Logon</h1>
>> <FORM METHOD=POST ACTION="/cgi-bin/scfbweb.py">
>> <INPUT TYPE=HIDDEN NAME="key" VALUE="process">
>> TO SERVER:<BR>
>> <INPUT type=text NAME="tosrv" value="TO" size=60>
>> FROM SERVER<BR>
>> <INPUT type=text name="fromsrv" value="FROM" size=60>
>> <INPUT TYPE="SUBMIT" VALUE="START">
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list