473,379 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

can't get cgi values

I'm having trouble extracting cgi parameters in my code - this is a web
application, so I only know the line that's causing the problem.

here's the info I know:

form = FieldStorage(None, None, [MiniFieldStorage('zid', '17'),
MiniFieldStorage('keywords', 'aAUA'), MiniFieldStorage('keywords',
'aBOS'), MiniFieldStorage('citation', '<i>The Earth Times Monthly</i>,
April 2002\\r\\n \\r\\n \r\n '),
MiniFieldStorage('quotation', 'Farm support goes mainly to a relatively
small number of agri-businesses, many of them large corps. Yet these
subsidies are 6 times what rich countries provide in foreign aid to a
developing world that includes 5 billion people.\\r\\n \r\n
'), MiniFieldStorage('updatebutton', 'Update')])
form.has_key("citation") = True

fileHandle.write("here aer the haskeys");
fileHandle.write( str(form.has_key("citation")))
/* returns TRUE */

temp = str(form("citation").value)
/* python stops here,

form("citation appears to be undefined */

print (str(form("citation").value))
/* this doesn't work, either */


if form.has_key("keywords"): /*
neither does this */
keywords = str(form["keywords"].value)
else:
keywords = "k"


any ideas on what the problem is?

thank you so much.

-rsr-

Nov 27 '06 #1
6 2868
form("citation").value

Is form some form of dict? If so, then this should be something like:

form["citation"]

If not, then maybe value is a function, requiring ()'s to actually invoke
it.

-- Paul
Nov 27 '06 #2
ronrsr wrote:
I'm having trouble extracting cgi parameters in my code - this is a web
application, so I only know the line that's causing the problem.
seen this:

http://docs.python.org/lib/module-cgitb.html

?
temp = str(form("citation").value)
did you perhaps mean form["citation"] ?

</F>

Nov 27 '06 #3
ronrsr wrote:
I'm having trouble extracting cgi parameters in my code - this is a web
application, so I only know the line that's causing the problem.
if exceptions try "import cgitb; cgitb.enable()" to get a traces directly in HTML for testing; otherwise read the server log (logs of httpd etc.) for traces
>
here's the info I know:

form = FieldStorage(None, None, [MiniFieldStorage('zid', '17'),
MiniFieldStorage('keywords', 'aAUA'), MiniFieldStorage('keywords',
'aBOS'), MiniFieldStorage('citation', '<i>The Earth Times Monthly</i>,
April 2002\\r\\n \\r\\n \r\n '),
MiniFieldStorage('quotation', 'Farm support goes mainly to a relatively
small number of agri-businesses, many of them large corps. Yet these
subsidies are 6 times what rich countries provide in foreign aid to a
developing world that includes 5 billion people.\\r\\n \r\n
'), MiniFieldStorage('updatebutton', 'Update')])
form.has_key("citation") = True

fileHandle.write("here aer the haskeys");
fileHandle.write( str(form.has_key("citation")))
/* returns TRUE */

temp = str(form("citation").value)
/* python stops here,

form("citation appears to be undefined */

print (str(form("citation").value))
/* this doesn't work, either */

try "form['citation']"

why the Python cgi module and the documentation is a horror, read: <ek**********@news.albasani.net>
Robert
>

if form.has_key("keywords"): /*
neither does this */
keywords = str(form["keywords"].value)
else:
keywords = "k"


any ideas on what the problem is?

thank you so much.

-rsr-
Nov 27 '06 #4
Thank you, all. that was very helpful, and did solve many of my
problems. I was addressing the dict with () rather than [].

I'm still having one problem, though -- extracting the keywords. NOw,
if you check the value for Form below, you'll see there is more than
one keyword entry. When I do: keywords = form["keywords"] - what sort
of data structure do I get back?

th anks so much again.

-rsr-
if form.has_key("keywords"):
keywords = str(form["keywords"].value)
else:
keywords = "k"
fileHandle.write("here comes keywords:")
fileHandle.write(str(keywords))

fileHandle.write("keyword info");
fileHandle.write(str(form.has_key("keywords")))
fileHandle.flush()
here's the info I know:

form = FieldStorage(None, None, [MiniFieldStorage('zid', '17'),
MiniFieldStorage('keywords', 'aAUA'), MiniFieldStorage('keywords',
'aBOS'), MiniFieldStorage('citation', '<i>The Earth Times Monthly</i>,
April 2002\\r\\n \\r\\n \r\n '),
MiniFieldStorage('quotation', 'Farm support goes mainly to a relatively
small number of agri-businesses, many of them large corps. Yet these
subsidies are 6 times what rich countries provide in foreign aid to a
developing world that includes 5 billion people.\\r\\n \r\n
'), MiniFieldStorage('updatebutton', 'Update')])
form.has_key("citation") = True

Nov 27 '06 #5
Thank you, all. that was very helpful, and did solve many of my
problems. I was addressing the dict with () rather than [].

I'm still having one problem, though -- extracting the keywords. NOw,
if you check the value for Form below, you'll see there is more than
one keyword entry. When I do: keywords = form["keywords"] - what sort
of data structure do I get back?

th anks so much again.

-rsr-
if form.has_key("keywords"):
keywords = str(form["keywords"].value)
else:
keywords = "k"
fileHandle.write("here comes keywords:")
fileHandle.write(str(keywords))

fileHandle.write("keyword info");
fileHandle.write(str(form.has_key("keywords")))
fileHandle.flush()
here's the info I know:

form = FieldStorage(None, None, [MiniFieldStorage('zid', '17'),
MiniFieldStorage('keywords', 'aAUA'), MiniFieldStorage('keywords',
'aBOS'), MiniFieldStorage('citation', '<i>The Earth Times Monthly</i>,
April 2002\\r\\n \\r\\n \r\n '),
MiniFieldStorage('quotation', 'Farm support goes mainly to a relatively
small number of agri-businesses, many of them large corps. Yet these
subsidies are 6 times what rich countries provide in foreign aid to a
developing world that includes 5 billion people.\\r\\n \r\n
'), MiniFieldStorage('updatebutton', 'Update')])
form.has_key("citation") = True

Nov 27 '06 #6
ronrsr wrote:
Thank you, all. that was very helpful, and did solve many of my
problems. I was addressing the dict with () rather than [].

I'm still having one problem, though -- extracting the keywords. NOw,
if you check the value for Form below, you'll see there is more than
one keyword entry. When I do: keywords = form["keywords"] - what sort
of data structure do I get back?

there is another func to get multiple values - see the docs.
Basically, one can iterate all over form.list (which is not documented) to get the original order of all the fields.

Robert

th anks so much again.

-rsr-
if form.has_key("keywords"):
keywords = str(form["keywords"].value)
else:
keywords = "k"
fileHandle.write("here comes keywords:")
fileHandle.write(str(keywords))

fileHandle.write("keyword info");
fileHandle.write(str(form.has_key("keywords")))
fileHandle.flush()
>here's the info I know:

form = FieldStorage(None, None, [MiniFieldStorage('zid', '17'),
MiniFieldStorage('keywords', 'aAUA'), MiniFieldStorage('keywords',
'aBOS'), MiniFieldStorage('citation', '<i>The Earth Times Monthly</i>,
April 2002\\r\\n \\r\\n \r\n '),
MiniFieldStorage('quotation', 'Farm support goes mainly to a relatively
small number of agri-businesses, many of them large corps. Yet these
subsidies are 6 times what rich countries provide in foreign aid to a
developing world that includes 5 billion people.\\r\\n \r\n
'), MiniFieldStorage('updatebutton', 'Update')])
form.has_key("citation") = True

Nov 27 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Bedford | last post by:
Here is some code I can't find the error in. I'm trying to fill a <select> with option coming from a database, and would like to select a previously selected record. For this, I set the value $City...
50
by: dataangel | last post by:
I wrote a function to compare whether two strings are "similar" because I'm using python to make a small text adventure engine and I want to it to be responsive to slight mispellings, like...
4
by: Steve Hall | last post by:
Folks, My secnario involves two tables - ObservationRegister, and Person. ObservationRegister contains most of the "useful" fields, including the UserID of the person that raised the record, and...
9
by: Vorpal | last post by:
Here is a small sample of data from a table of about 500 rows (Using MSSqlserver 2000) EntryTime Speed Gross Net ------------------ ----- ----- 21:09:13.310 0 0 0 21:09:19.370 9000 ...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
14
by: Rich | last post by:
Yes, I need to store some values in an array type collection object that can hold 3 or more parameters per index. I have looked at the collection object, hashtable object and would prefer not to...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
19
by: octangle | last post by:
This code is attempting to find records that have a RegJrnID that does not occur more than one time in the table. The reason that I want to find records with non-duplicated RegJrnID values is to...
6
by: Alvin SIU | last post by:
Hi all, I have a table in Db2 v8 like this: Team Name Role ------ -------- --------------------- A Superman Leader A Batman Member A WonderWoman Member B ...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.