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

Search Discussions

  • Fredrik Lundh at Nov 27, 2006 at 6:40 pm

    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>
  • Paul McGuire at Nov 27, 2006 at 6:41 pm
    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
  • Robert at Nov 27, 2006 at 6:51 pm

    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: <ek6ncq$7pp$1 at 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-
  • Ronrsr at Nov 27, 2006 at 7:48 pm
    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
  • Robert at Nov 27, 2006 at 8:11 pm

    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
  • Ronrsr at Nov 27, 2006 at 7:58 pm
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 27, '06 at 6:28p
activeNov 27, '06 at 8:11p
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase