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

Discussion in 'Python' started by Stef Mientki, Nov 11, 2010.

  1. Stef Mientki

    Stef Mientki Guest

    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 Mientki, Nov 11, 2010
    #1
    1. Advertising

  2. Stef Mientki

    r0g Guest

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

    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.
    r0g, Nov 11, 2010
    #2
    1. Advertising

  3. Stef Mientki

    Roy Smith Guest

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

    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.
    Roy Smith, Nov 12, 2010
    #3
  4. Stef Mientki

    r0g Guest

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

    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
    r0g, Nov 15, 2010
    #4
  5. Stef Mientki

    Roy Smith Guest

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

    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.
    Roy Smith, Nov 15, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,743
    Darryl Pierce
    Feb 24, 2005
  2. Kerim Borchaev

    super. could there be a simpler super?

    Kerim Borchaev, Jan 15, 2004, in forum: Python
    Replies:
    4
    Views:
    470
    Michele Simionato
    Jan 15, 2004
  3. Rajive Narain
    Replies:
    0
    Views:
    1,575
    Rajive Narain
    Sep 18, 2009
  4. Steve Holden
    Replies:
    4
    Views:
    195
    Neil Cerutti
    Nov 12, 2010
  5. Stef Mientki
    Replies:
    2
    Views:
    272
    Paul Watson
    Nov 11, 2010
Loading...

Share This Page