Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > is there an Python equivalent for the PHP super globals like $_POST,$_COOKIE ?

Reply
Thread Tools

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

 
 
Stef Mientki
Guest
Posts: n/a
 
      11-11-2010
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
 
Reply With Quote
 
 
 
 
r0g
Guest
Posts: n/a
 
      11-11-2010
On 11/11/10 14:22, 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



PHP only tends to be run one way, the mod_php Apache module. There's
several ways run python in conjunction with a webserver like apache:
mod_wsgi, mod_python, CGI and FastCGI. I've never really looked into
this way of doing things but I guess the details are going to vary
depending on which one you use.

It's also not uncommon for python to actually BE the webserver too,
there's lots of webserver modules for python, cherrypy is fairly simple
and well regarded. Often you can proxy these through Apache to get the
benefits of both although again, that's not an approach I've used so I
can't really advise you further.

Roger.
 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      11-12-2010
In article <ibhi4h$evv$>,
r0g <> wrote:

> On 11/11/10 14:22, Stef Mientki wrote:
>> I can't find how th get to PHP's equivalent of $_Post and $_Cookie ?


PHP is mostly a one-trick pony. It's meant to be run as a web scripting
language with Apache (or, I suppose, something else) on the front end.
As a result, a lot of web-specific things like $_Post and $_Cookie are
built into the language.

Python is intended to be more general purpose, so things which are built
in to other languages usually can be found in library modules. In this
case, you probably want to look at the SimpleHTTPServer module.

You may also want to look at any of several web application frameworks
such as Django, Pylons, etc. I'm guessing these are overkill for the
sorts of things you want to do, but they're worth at least browsing to
get some idea of what's out there.

For what it's worth, I've pretty much avoided PHP for all these years.
My latest gig, however, has had me doing PHP for the past 3 months or
so. The more I learn about PHP, the more I want to go running in the
other direction.
 
Reply With Quote
 
r0g
Guest
Posts: n/a
 
      11-15-2010
On 12/11/10 01:25, Roy Smith wrote:
> In article<ibhi4h$evv$>,
> r0g<> wrote:
>
>> On 11/11/10 14:22, Stef Mientki wrote:
>>> I can't find how th get to PHP's equivalent of $_Post and $_Cookie ?

>
> PHP is mostly a one-trick pony. It's meant to be run as a web scripting
> language with Apache (or, I suppose, something else) on the front end.
> As a result, a lot of web-specific things like $_Post and $_Cookie are
> built into the language.
>
> Python is intended to be more general purpose, so things which are built
> in to other languages usually can be found in library modules. In this
> case, you probably want to look at the SimpleHTTPServer module.
>



Actually when they say "Simple" they really mean it. The the
SimpleHTTPServer module doesn't parse form data at all. It's pretty easy
to get that using the urlparse module though...


def do_GET(self):
getvars = urlparse.parse_qs( self.path )
field1 = getvars[ "username" ][0]
field2 = getvars[ "password" ][0]
if authenticate( field1, filed2 ):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write( "welcome" )
else:
self.send_response(404)
self.end_headers()
return

This may be lower level than you want really and does involve
permanently running a daemon on your server as opposed to the PHP way of
doing things (having Apache interpret PHP on a page by page basis).



> My latest gig, however, has had me doing PHP for the past 3 months or
> so.


That's terrible, you have my fullest sympathy in these difficult times.


Roger
 
Reply With Quote
 
Roy Smith
Guest
Posts: n/a
 
      11-15-2010
In article <ibr0tl$ai9$>,
r0g <> wrote:

> > My latest gig, however, has had me doing PHP for the past 3 months or
> > so.

>
> That's terrible, you have my fullest sympathy in these difficult times.


Actually, in a sick sort of way, it's fun. We regularly have PHP
bashing sessions in the office when somebody discovers yet another
depraved piece of language mis-design and we all get a good laugh out of
it. No all languages afford you the opportunity for this kind of
entertainment.

It's also quite educational. You can learn a lot about language design
by observing the mistakes that can be made.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: is there an Python equivalent for the PHP super globals like$_POST, $_COOKIE ? Steve Holden Python 4 11-12-2010 01:54 PM
Re: is there an Python equivalent for the PHP super globals like$_POST, $_COOKIE ? Stef Mientki Python 2 11-11-2010 08:24 PM
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
super.super.super how? Java 24 02-24-2005 10:51 PM
super. could there be a simpler super? Kerim Borchaev Python 4 01-15-2004 03:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57