Using CGI module with 'canned queries'
Lars von Wedel
lvw at lfpt.rwth-aachen.de
Wed Apr 19 08:01:01 EDT 2000
Paul,
The %'s were obviously wrong, but they got mixed up when I
transferred the string from '%s:%s...' % (a,b,c) into the e-mail
where I wrote some bogus stuff.
Indeed I overlookes the .value attribute of the keys.
Thanks,
Lars
Paul Boddie writes:
> Lars von Wedel wrote:
> >
> > Hello,
> >
> > I want to use Python to implement some CGI scripts. I want these
> > scripts to be callable from any link (not only via a form),
> > e.g. the user shall be able to enter something like
> >
> > http://.../test.py?name=Bill
> >
> > into Netscape directly.
>
> The parameter(s) should still be received correctly in the CGI script.
>
> > I expected that such a URL could be processed using
> >
> > form = cgi.FieldStorage() print '<UL>'
> > for k in form.keys:
> > print '<LI>' % k % ':' % form[k] % '</LI>'
>
> Surely you mean...
>
> print '<LI>' + k + ':' + form[k].value + '</LI>'
>
> > (after printing an html header of course).
> >
> > However, the dictionary seems to be empty when the http daemon
> > starts my script.
>
> Are you sure that the problem doesn't lie in the fact that form[k] is not likely
> to be a string, but a FieldStorage object instead? Thus, you must refer to the
> value attribute of form[k].
>
> > How do I access parameters within the script if not started via a form?
>
> You should be able to do just that with the 'cgi' module.
>
> Paul
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list