A couple of Python CGI questions

sean sean_berry at cox.net
Tue Mar 30 08:41:27 CEST 2004


Figured that one out too.

form = cgi.FireldStorage()
userid = form.getfirst("userid")

print userid

Does this work that same for forms?  Since this is get, and most forms will
be post... can I collect post variables in the same fashion?


"sean" <sean_berry at cox.net> wrote in message
news:2z8ac.65499$Bg.26470 at fed1read03...
> What about collection variables passed via the URL... like
> someprogram.cgi?userid=Seam
>
> How would I collect the userid = Sean part?
>
> Thanks in advance.
>
> "sean" <sean_berry at cox.net> wrote in message
> news:9g8ac.65379$Bg.14309 at fed1read03...
> > I tried getting mod_python to work but have had lots of problems getting
> it
> > running.  So, I have settled on using python cgi.
> >
> > I have already got it going and it seems to run fast enough for me.
> >
> > My questions are:
> > 1.  Is there any way to access variables from within a string like perl
> cgi?
> > I have found that the best way for me to write html tables is to use a
> print
> > """<blah blah blah>""" string.  That way I can write one print """, and
> then
> > write html as if I were writing an html file.  For example:
> > print """
> > <table border="0" cellspacing="0">
> > <tr>
> >     <td>This is cool</td>
> > </tr>
> > </table>
> > """
> > I really like this and it is a lot like typing the following in Perl
cgi:
> > print <<EOF
> > <table border="0" cellspacing="0">
> > <tr>
> >     <td>This is cool</td>
> > </tr>
> > </table>
> > EOF
> >
> > So, is there any way to access variables from within the string, besides
> > using %s?  In perl, I just put the $variable in the string and it
replaces
> > the varname with the value.
> >
> > 2.  Is there a good online resourse for pyton cgi?
> > 3.  How do you collect request variables from forms sent to the python
cgi
> > page, whether post or get?
> >
> >
> > Thanks very much for the help... I will continue to google for my
answers.
> >
> > Sean
> >
> >
> >
>
>





More information about the Python-list mailing list