can't get cgi values

R

ronrsr

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-
 
P

Paul McGuire

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
 
R

robert

ronrsr said:
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: <[email protected]>


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-
 
R

ronrsr

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()
 
R

ronrsr

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()
 
R

robert

ronrsr said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top