By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

can't get cgi values

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.