Question using CGI in Python
Shane Anglin
shane.anglin at mtni.net
Tue Aug 28 15:39:58 EDT 2001
In very abbreviated form: This is not a functional anything... I have to
use 3 pages to accomplish this task using HTML, Python, and PostgreSQL.
1- App1.py is used to submit a variable that is passed to App2.py.
2 - App2.py gets variable from App1.py, then, depending on variable value,
pulls other content from database and creates a HTML form for entering more
data.
3 - App3.py should get data that was submitted from App2.py.
My problem is getting App2.py to place the variable sent from App1.py and
combine that variable with all variables from App2.py, and sending all to
App3.py for processing... in essence, carrying over variables from many
pages and lumping them all together into the last page.
Is there a way to place it into the input stream when using POST... or
should I use GET and then how and where to place it into the QUERY_STRING?
Non-working example:
--app1.py:
print "<FORM METHOD='POST' ACTION='app2.py'>
print '<input type="text" size="10" name="var1">'
print "<P><INPUT type='submit' value='Submit'></P>"
</FORM>
#SUBMIT
--app2.py:
form = cgi.FieldStorage()
VAR1 = form["var1"].value
#some database stuff happens
print "<FORM METHOD='POST' ACTION='app3.py'>
print '<input type="hidden" name=VAR1>' # this doesn't work..it seds a
literal string of VAR1 and not the variable
print '<P><input type="text" size="10" name="TEXT1"></P>
print "<P><INPUT type='submit' value='Submit'></P>"
print "</FORM>"
#SUBMIT
app3.py:
form = cgi.FieldStorage()
# print all enviromental variables
for key in os.environ.keys():
print key + os.environ[key] + '<br>'
print form["VAR1"].value
print form["TEST1"].value
Thanks,
Shane Anglin
shanenaglin at bigfoot.com
More information about the Python-list
mailing list