is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?

Stef Mientki stef.mientki at gmail.com
Thu Nov 11 13:56:07 EST 2010


On 11-11-2010 19:36, david wright wrote:
>
> ----------------------------------------------------------------------------------------------------
> *From:* Stef Mientki <stef.mientki at gmail.com>
> *To:* python-list at python.org
> *Sent:* Thu, November 11, 2010 10:20:03 AM
> *Subject:* Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
>
> On 11-11-2010 19:01, Steve Holden wrote:
> > On 11/11/2010 9:22 AM, Stef Mientki wrote:
> >> hello,
> >>
> >> finally got Python running at my server.
> >>
> >> Now I would like to replace the PHP server scripts with Python ( for easier maintenance).
> >>
> >> But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ?
> >> Google finds lots of links, but I can't find the answer.
> >>
> >> thanks,
> >> Stef Mientki
> > Stef:
> >
> > Moving from one language to anther is not just a matter of
> > transliterating the code. Of you try that you will end up with a messy
> > code base that looks like PHP written in Python.
> - Steve I agree with you,
> - but  replacing a number of 3 to 10 lines of code scripts won't create a mess ;-)
>
> So, assuming you want the 'straight ahead' (i.e. no framework, like Django) your looking
> at vanilla CGI programming.
>
> form = cgi.FieldStorage() # parse query string, handles decoding and GET and POST 
>
> print "<p>name:", form["name"].value
>
> http://docs.python.org/library/cgi.html
thanks David,
looks that was what I was looking for,
I'll investigate all the properties of Fieldstorage.

thanks,
Stef
> Enjoy! :)
> David
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101111/eadbc94e/attachment-0001.html>


More information about the Python-list mailing list