[Tutor] cgi.FieldStorage and dictionary.get(' ')

Luis N tegmine at gmail.com
Fri Dec 31 02:00:14 CET 2004


I've passed this through the interperter line-by-line, yet still can't
get it to work right.

The first time the cgi driver script initiates it runs the login
function which renders a zpt. Upon submission of their vitals,  the
user is authenticated via sqlobject, and if they pass the chapters
function should run. However, what I get is zip, zilch, nada. Just a
blank page, with the query string appended to the url.

def main(form):
   if form.has_key('author') and form.has_key('password'):
      q = Users.select(AND(Users.q.author==form.get('author'),
      if len(list(q))>0:

Out of curiosity I wrote a simple test cgi.


print 'Content-type: text/plain\n\n'

import cgi

form = cgi.FieldStorage()
if form.has_key('author') and form.has_key('password'):
        print form.keys()
        print form.get('author')
        print form.get('password')

Strangely, the calls to print form.get('author') and
form.get('password') don't appear in the output. Only the form.keys()

Additionally, why doesn't def main(form=cgi.FieldStorage()) work, I
tried to do it as so, thinking it more graceful, and it floundered.

More information about the Tutor mailing list