Python Apache Handler

Discussion in 'Python' started by Scooter, Jan 9, 2009.

  1. Scooter

    Scooter Guest

    Does anyone have any good examples, or links thereto for using python
    as an Apache handler? And I should qualify all of this by saying I'm a
    python newbie, and while having experience with Apache, I've never
    done anything outside whats "in the box" .

    What I'm looking for is how one might use Python not from the CGI/
    presentation side but more on the backend...i.e. for each page Apache
    serves up examine the request and update some headers, or add a cookie
    to the response. Or possibly use Python for writing a custom Apache
    logger. I've searched the web but typically end up with pages for
    mod_python and writing CGI scripts.

    And if you feel this is better posted in an Apache group vs. here, let
    me apologize up front.

    Thanks
    Scooter, Jan 9, 2009
    #1
    1. Advertising

  2. Scooter wrote:
    > Does anyone have any good examples, or links thereto for using python
    > as an Apache handler? And I should qualify all of this by saying I'm a
    > python newbie, and while having experience with Apache, I've never
    > done anything outside whats "in the box" .
    >
    > What I'm looking for is how one might use Python not from the CGI/
    > presentation side but more on the backend...i.e. for each page Apache
    > serves up examine the request and update some headers, or add a cookie
    > to the response.


    I vaguely remembered that mod_python can do such things. Looking again
    it seems to be the case:
    http://www.modpython.org/live/current/doc-html/pyapi-filter.html

    > Or possibly use Python for writing a custom Apache
    > logger. [...]


    Maybe http://www.modpython.org/live/current/doc-html/dir-handlers-plh.html
    The documentation about this is a joke, though.

    Remember that you can write custom Apache loggers quite easily with
    "piped logs": http://httpd.apache.org/docs/2.2/logs.html

    This looks roughly like this:

    CustomLog "|/path/to/my_script.py" common

    ## begin my_script.py ##
    import sys

    for line in sys.stdin:
    # do stuff
    ## end ##

    -- Gerhard
    Gerhard Häring, Jan 9, 2009
    #2
    1. Advertising

  3. Scooter

    Sells, Fred Guest

    Mod_python works, but if you are doing anything significant look into
    one of the many frameworks like turbogears or django. More structure to
    learn but less code when all is said and done.

    > -----Original Message-----
    > From: python-list-bounces+frsells=
    > [mailto:python-list-bounces+frsells=] On
    > Behalf Of Scooter
    > Sent: Friday, January 09, 2009 9:37 AM
    > To:
    > Subject: Python Apache Handler
    >
    > Does anyone have any good examples, or links thereto for using python
    > as an Apache handler? And I should qualify all of this by saying I'm a
    > python newbie, and while having experience with Apache, I've never
    > done anything outside whats "in the box" .
    >
    > What I'm looking for is how one might use Python not from the CGI/
    > presentation side but more on the backend...i.e. for each page Apache
    > serves up examine the request and update some headers, or add a cookie
    > to the response. Or possibly use Python for writing a custom Apache
    > logger. I've searched the web but typically end up with pages for
    > mod_python and writing CGI scripts.
    >
    > And if you feel this is better posted in an Apache group vs. here, let
    > me apologize up front.
    >
    > Thanks
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    Sells, Fred, Jan 9, 2009
    #3
    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. shruds
    Replies:
    1
    Views:
    791
    John C. Bollinger
    Jan 27, 2006
  2. Replies:
    1
    Views:
    695
    Damien
    Feb 22, 2007
  3. Replies:
    0
    Views:
    352
  4. joe jacob
    Replies:
    3
    Views:
    702
    joe jacob
    Aug 14, 2007
  5. mannewalis
    Replies:
    1
    Views:
    901
    Graham Dumpleton
    Oct 17, 2007
Loading...

Share This Page