Mod_python vs. application server like CherryPy?

Graham Dumpleton grahamd at dscpl.com.au
Wed Dec 6 19:32:14 EST 2006


Vincent Delporte wrote:
> On 6 Dec 2006 14:55:58 -0800, "Graham Dumpleton"
> <grahamd at dscpl.com.au> wrote:
> >Although WSGI is an extreme case because of the level it pitches at,
> >other systems such as CherryPy and Django aren't much different as they
> >effectively duplicate a lot of stuff that could be achieved using more
> >basic functionality of Apache as well.
>
> Mmm... So how can I use those goodies from Apache? Just through their
> configuration files, or do I have to somehow call them from Python?
>
> Is the fact that Python developers tend to ignore resources in Apach
> due to difficulties in making calls from Python, making the scripts
> unpythonic?

It depends on what you are doing. For example, if you need to do URL
rewriting, you use the mod_rewrite module for Apache, not that it is
the most pleasant thing to use. If you need to proxy through some
subset of requests to a downstream web server, use mod_proxy. If you
need to compress content going back to clients, use mod_deflate. If you
need to do caching you use mod_cache.

How to configure each of these from the Apache configuration files, you
need to look at the Apache httpd documentation at httpd.apache.org.

Some, like mod_proxy and mod_deflate can be triggered from within
mod_python although finding the magic required isn't always straight
forward. How you setup responses can also control mod_cache.

If anything, the reason that Python developers tend to ignore a lot of
what Apache has to offer is that it means understanding Apache. The
Apache documentation isn't always the easiest thing to understand and
for some things it even requires looking at the Apache source code to
work out how to do things. The mod_python documentation at the moment
doesn't help either, as it doesn't provide much in the way of recipes
for doing things. The new mod_python wiki will hopefully address that
over time, but right now the mod_python mailing lists are the best it
gets.

In terms of whether it is 'unpythonic', what should be more important
is whether it gets the job done in a way that makes best use of what is
available. If you want something to be 'pythonic', then using Apache as
a framework probably isn't what you want, as as I said previously it
becomes more about integrating things rather than writing pure Python
code.

Getting perhaps back to the answer you were seeking right back at the
start, that is if you are new to web application and development and
Python, then you may well be better of just using a higher level
framework as they will make it easier and isolate you from any pains in
understanding Apache and how to use it properly.

Graham




More information about the Python-list mailing list