473,893 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mod_python vs. application server like CherryPy?

Hi

I'm still a newbie when it comes to web applications, so would like
some help in choosing a solution to write apps with Python: What's the
difference between using running it through mod_python vs. building an
application server using Python-based tools like CherryPy, Quixote,
Draco, etc.?

Thanks.
Dec 5 '06 #1
10 4965
Vincent Delporte wrote:
I'm still a newbie when it comes to web applications, so would like
some help in choosing a solution to write apps with Python: What's the
difference between using running it through mod_python vs. building an
application server using Python-based tools like CherryPy, Quixote,
Draco, etc.?
Well, let me start by saying that anything you can build with CherryPy,
you can build with mod_python. In a nutshell, mod_python gives you
access from Python to the Apache API, whereas CherryPy and friends give
you their own API.

I joined the CherryPy development team because I liked CherryPy's API
better, and at the time, needed to deploy my site on IIS, not Apache. I
continue to use the same site, written with CherryPy, but now using
Apache (and even mod_python!) to serve it. CherryPy allows me to focus
on the application layer and leave the server/deployment layer for
another day.

In other words, there's nothing about mod_python that leaves it out of
the "applicatio n server" category per se. The publisher handler, in
particular, is an example of an "applicatio n server" built on top of
mod_python's base API, and has some strong similarities to CherryPy's
traversal and invocation mechanisms. But IMO CherryPy has a cleaner API
for process control (engines and servers), application composition (via
the object tree and via WSGI), and plugins (like gzip, static content,
and header management).
Robert Brewer
System Architect
Amor Ministries
fu******@amor.o rg

Dec 6 '06 #2
On 5 Dec 2006 17:05:06 -0800, "fumanchu" <fu******@amor. orgwrote:
>In a nutshell, mod_python gives you
access from Python to the Apache API, whereas CherryPy and friends give
you their own API.
I didn't know Apache had an API of its own, or that it was even needed
when writing a web application in Python. What does it provide in
addition to Python/mod_python?
CherryPy allows me to focus
on the application layer and leave the server/deployment layer for
another day.
So you recommend using Apache as the front-end, and run an application
server like CherryPy in the background?
But IMO CherryPy has a cleaner API
for process control (engines and servers), application composition (via
the object tree and via WSGI), and plugins (like gzip, static content,
and header management).
Interesting. I'll see if I can find more information on writing an app
with Python in pure CGI, in FastCGI, in mod_python, and as an
application server with eg. CherryPy.

Thanks.
Dec 6 '06 #3
Vincent Delporte wrote:
On 5 Dec 2006 17:05:06 -0800, "fumanchu" <fu******@amor. orgwrote:
In a nutshell, mod_python gives you
access from Python to the Apache API, whereas CherryPy and friends give
you their own API.

I didn't know Apache had an API of its own, or that it was even needed
when writing a web application in Python. What does it provide in
addition to Python/mod_python?
mod_python provides different layers of APIs, with the lowest levels
being those dealing with things like connections and requests - see the
apache module for details:

http://www.modpython.org/live/curren...le-apache.html

Other layers involve things like cookies, sessions and Python server
pages, and there are also things like the publisher handler which are
less to do with Apache itself and more to do with Python:

http://www.modpython.org/live/curren.../hand-pub.html

Paul

Dec 6 '06 #4

Vincent Delporte wrote:
On 5 Dec 2006 17:05:06 -0800, "fumanchu" <fu******@amor. orgwrote:
In a nutshell, mod_python gives you
access from Python to the Apache API, whereas CherryPy and friends give
you their own API.

I didn't know Apache had an API of its own, or that it was even needed
when writing a web application in Python. What does it provide in
addition to Python/mod_python?
Although Apache does have a quite considerable underlying API of its
own, mod_python doesn't actually provide direct access to much of it
from Python code. What mod_python does provide is still adequate for
getting basic stuff done, but Apache could perhaps be better harnessed
if all the Apache API were exposed and available.

Where the power of Apache comes into play is the ability to compose
together the functionality of different Apache modules to build up an
application. That is, you aren't just doing everything in Python code.
That said though, this doesn't mean you have to go off and write code
in another language such as C. This is because the Apache modules are
glued together through the Apache configuration files with some
features also being able to be enabled from Python code running under
mod_python.

In some respects you need to see the whole of Apache as being a
platform for building a web application. Unfortunately, most Python web
application developers don't see that and simply use Apache as a
convenient hopping off point for the main content handling phase of a
request. Even where people do write stuff which makes use of mod_python
as more than just a hopping off point, more often than not they still
work within just mod_python and don't bring in other parts of Apache to
any degree.

For example, consider an extreme case such as WSGI. Through a goal of
WSGI being portability it effectively ignores practically everything
that Apache has to offer. Thus although Apache offers support for
authentication and authorisation, a WSGI user would have to implement
this functionality themselves or use a third party WSGI component that
does it for them. Another example is Apache's support for enabling
compression of content returned to a client. The WSGI approach is again
to duplicate that functionality. Similarly with other Apache features
such as URL rewriting, proxying, caching etc etc.

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. Once one starts to make use of
the underlying Apache functionality, you are binding yourself to Apache
though and your stuff isn't portable to other web servers. Also, your
job in part becomes more about integrating stuff to come up with a
solution, rather than just writing pure Python code, something that
many Python coders possibly wouldn't find appealing. :-)

Graham

Dec 6 '06 #5
On 6 Dec 2006 14:55:58 -0800, "Graham Dumpleton"
<gr*****@dscpl. com.auwrote:
>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?
Dec 6 '06 #6

Vincent Delporte wrote:
On 6 Dec 2006 14:55:58 -0800, "Graham Dumpleton"
<gr*****@dscpl. com.auwrote:
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.or g.

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

Dec 7 '06 #7
On 6 Dec 2006 16:32:14 -0800, "Graham Dumpleton"
<gr*****@dscpl. com.auwrote:
>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
understandin g Apache and how to use it properly.
Thanks a lot for the feedback. It's beginning to make sense :-)
Dec 7 '06 #8
Graham Dumpleton wrote:
For example, consider an extreme case such as WSGI.
Through a goal of WSGI being portability it effectively
ignores practically everything that Apache has to offer.
Thus although Apache offers support for authentication
and authorisation, a WSGI user would have to implement
this functionality themselves or use a third party WSGI
component that does it for them. Another example is
Apache's support for enabling compression of content
returned to a client. The WSGI approach is again to
duplicate that functionality. Similarly with other Apache
features such as URL rewriting, proxying, caching etc etc.
Well, almost. I use Auth* directives for authentication (and the
Require directive for authorization) with my CherryPy apps. Many other
CP users use mod_rewrite and mod_proxy. So the WSGI user doesn't *have*
to implement that functionality themselves. Any sufficiently-messianic
framework will probably do so ;), but even the best admit there are
always alternatives.
Robert Brewer
System Architect
Amor Ministries
fu******@amor.o rg

Dec 7 '06 #9
For example, consider an extreme case such as WSGI. Through a goal of
WSGI being portability it effectively ignores practically everything
that Apache has to offer. Thus although Apache offers support for
authentication and authorisation, a WSGI user would have to implement
this functionality themselves or use a third party WSGI component that
does it for them.
OTOH
WSGI auth middleware already supports more auth methods than apache2 itself.
Another example is Apache's support for enabling
compression of content returned to a client. The WSGI approach is again
to duplicate that functionality.
the gzip middleware is really just an example... nobody would use that in
production.
Similarly with other Apache features
such as URL rewriting, proxying, caching etc etc.
Well, not everybody can use Apache ... and again there's already WSGI
middleware that's more flexible than the Apache modules for most of the
features you mention.

It's not that I think mod_python doesn't have uses.. I just think it's not
practical to make python web applications targeted solely to mod_python.

--
damjan
Dec 9 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2297
by: wolf | last post by:
i would like to briefly share my experiences with installing mod_python on a w2000 box. i must say that i believe the installation process to be unnecessarily complicated by the simple fact that the installer itself seems to be buggy -- in my case, no combination of mod_python 3.0.4, 3.1.2b and python 2.2.3, 2.3.3 ever came to completion. rather, the installer would exit -- after an initial declaration of having successfully found python...
3
1765
by: flab ba | last post by:
Hello: I am new to web app programming, but need to create a web app. I would like to do it in Python After extensive googling, reading news groups, blogs, and outdated / incomplete "web app shoot outs" that don't seem to come to any conclusion, I came across a number of alternatives, but my limited knowledge in this field prevents me from seeing the virtues of one framework over the other. The ones I saw were:
2
2930
by: digidalmation | last post by:
Hello all. I've been trying to get my linux server to run mod_python. It's a Mandrake 10 linux box, and apache/mod_python are installed from rpms. apache2-mod_python-2.0.48_3.1.3-1mdk apache2-2.0.48-6mdk The rpm installed the python module as: /usr/lib/apache2-extramodules/mod_python.so And added a config file for apache:
6
1951
by: Anthony L. | last post by:
I am writing a web application that is comparable to a content management system used in blogging. I really want to use Python after having done some evaluation coding using Python 2.3.5 with mod_python 3.1.4 running on Apache 2.0 with the Publisher handler. However, I am still very hesitant to settle on Python. All my research brings up the same collection of scant articles and old mailing list messages that reference each other. I am...
1
4365
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req): req.content_type = 'text/plain' req.write("Under Construction")
10
1432
by: walterbyrd | last post by:
I am considering python, instead of php, for web-application development. I often see mod_python.criticisized as being borked, broken, or just plain sucking. Any truth to any of that?
7
1831
by: Ben Finney | last post by:
Howdy all, I'm working on a web application that is starting to gain a lot of back-end code written in Python. However, all the current interface code is written in legacy PHP. I'd like to slowly introduce new features as Python WSGI programs. Is it possible to write a Python WSGI program that talks to a PHP program as its "back end"? Where can I find out how to do this, preferably with examples?
5
3128
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major issue ? thanks for any help.
9
2221
by: Rory Campbell-Lange | last post by:
We have a set of classes using static methods to retain reference variables between operations. The problem is that the static variables are not reset between operations when used through mod_python. Although it is possible to reset the class variables between invocations of the system, this has the potential of 'wiping out' these variables when another user is using the system. Is there a way of getting the equivalent of 'local class...
0
9985
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11243
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10469
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7173
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5858
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4280
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.