[mod_python] focus on shared hosting?

Martijn Moeling martijn at xs4us.nu
Fri Dec 22 06:51:01 EST 2006


I am building a mod_pthon application which is growing towards a web
development system (more on that later on). It is on a production
platform for over a year now and fortunately that project had the budget
to get a dedicated server. The hosting provider has been extremely
flexible in supporting a mod_python setup, and I am sure THEY will
support MP in a virtual host environment if I ask them to do so.

I found out that the larger the provider the less they are flexible on
non standard setups or additional software like mod_python. Try and seek
a well established provider which specializes on hosting and not on
internet access and prepare a list of questions/demands before you
contact them like:

Do you support Mod_python (obvious)
Would you if you don't
Can I modify the .htaccess
What extensions within python can I use (MySQLdb for instance)

Now a little on my application:

You can find it running on http://www.lokalos.nl (or the
http://www.mkbok.nl is the production example) Which is one of the
domains on my development server. It is based on a self made templating
system and all data (except for some images at the moment) is stored in
a MySQL database, that is templates, template blocks, data. The basic
module can be extended with separate modules, which are stored in the
database to (3.3.0b is used now for module reloading and beta-testing).
The database can contain additional tables which can be altered from
within the backoffice
(sorry for everything being in Dutch, the screen dump is to get an

This backoffice turns a browser into a desktop, and the next major thing
I am working on is a python to javascript converter so even the browser
can be programmed with python (with support for all major browsers). The
IDE will be something like Visual basic 6.0 but web based and completely
Users can be members of groups and membership of one adds functionality
to the menu on top.

As you can see in mkbok my system can be used to implement subdomains,
meaning xxx.mkbok.nl or even xxx.yyy.zzz.ppp.mkbok.nl, all database
driven, In the early days of my development I used to refer to my system
as a PMS (Portal Management System, and the original reason for starting
this developmen) but by now it is becoming an application development
system since I get more and more request from customers who want to let
their customers use the backoffice, or as I signed the contract this
morning one of my customers will be relying fully on this system to
implement their business logic and kick out M$ software completely,
replacing XP by linux with firefox and no other software as sort of
relatively dumb terminal with a 2 linux server redundant setup, running
apache, mysql and mod_python (and sendmail).

I am far from releasing this, but I am thinking of making it available
under GPL. Within this system a virtual host setup can be made, leaving
the apache config to no more than a AddHandler or SetHandler

The needed apache Config is:
<VirtualHost *:80>
	DocumentRoot /var/www/html

PythonOptimize On
# New in MP 3.3.0b:
PythonOption mod_python.importer.path ["/usr/bin/PMS"]

<Directory "/var/www/html">
	AddHandler mod_python .py
	PythonHandler generate
	PythonAutoReload On

#access to the backoffice
<Location "/admin/">
	SetHandler mod_pthon
	PythonHandler generate
	PythonAutoReload On

(I left out the SSL stuff)

With a request I look at req.connection.host to see which domain is
wanted and I open the corresponding MySQL database and read the right

This story might be an eye opener to some of you and any comments are
welcome. Shoot questions if you want.

Martijn Moeling

-----Oorspronkelijk bericht-----
Van: mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org] Namens Jim Gallacher
Verzonden: Friday, December 22, 2006 6:16 AM
Aan: Anthony
CC: mod_python at modpython.org
Onderwerp: Re: [mod_python] focus on shared hosting?

Anthony wrote:
>> Are there really security or resource utilization issues that can't
>> over come?
> Yes. Many shared hosting admins contend that they can't isolate
> virtual hosts for one reason or another. Considering that their target
> market for shared hosting is made up of more bloggers and
> blogger/hobbyist programmers than seasoned developers who will be
> extra careful with their processes, I suppose it's reasonable for an
> admin to be afraid.

I'm not sure mod_python is any worse as far as resource utilization is 
concerned. Mod_python 3.0 had the reputation of leaking memory, but 3.2 
fixed alot of the leaks and 3.3 will fix a couple more and in fact is 
looking pretty good on that front. On the other hand isolating virtual 
hosts is going to be difficult because of limitations imposed by the 
interpreter, and I don't see any easy fix. The ultimate answer is 
something like the (now dead) perchild-mpm, but there doesn't seem to be

much movement in that direction in httpd-land.

> A nifty screencast would be great though, if only to inspire. A demo
> site running small mod_python apps would be great too. I just wrote a
> small CGI app that let's me load up random Garfield comic strips, but
> a cool Ajaxy Flickr/eBay/Amazon search tool would be impressive.
> Admins and hobbyists who want to experiment need to be enticed by
> these presentations... showmanship.

Not just showmanship. I think the screencast idea is pretty good and 
I've certainly seen some that were quite educational. It seems to me 
they work best when you have some sort of GUI to explain though. As good

as screencasts may be, is there anything worse than watching someone 
type code into an editor?

> I believe if we want to see mod_python widespread on shared hosts, we
> should promote mod_python 2.7 on Apache 1.3. *ducks* 

And so you should. Mod_python 2 is dead. It's not resting. It's not 
pining for the fiords, it's not stunned. It's dead. It's pushin' up the 
daisies! 'Is metabolic processes are now 'istory! 'E's off the twig! 
'E's kicked the bucket, 'e's shuffled off 'is mortal coil, run down the 
curtain and joined the bleedin' choir invisibile!!

It is, in a word, an Ex-module.

(Gee, I wonder if it was a mistake to check my email after a couple of 
pints down at the local?)

> I use mod_python
> 3 on Apache 2 on my test system, but out there in shared hosting land,
> Apache 1.3 support is a generally a must. I admit I don't know much
> about the differences between MP2 and MP3, but what if MP2 were
> designed specifically to meet the needs of shared hosting admins? A
> kind of mod_python lite if you will.

I've come to accept that the sweet spot for mod_python is somewhat 
higher up the food chain from cheap shared hosting. Mod_python will come

into it's own as server virtualization becomes the rule for website

The code for mod_python 2 hasn't really been touched since 2002, and 
Apache 1.3 is considered legacy code as well. Many of the things that I 
find interesting and exciting about mod_python depend on Apache 2 
features. I think it would be hard to find people willing to spend time 
making mod_python 2.x work properly when you consider that it's 
ultimately a dead end. I'd much rather see our resources spent on 
improving the documentation (a widely acknowledged weakness), exploiting

Apache 2.2 features and general performance improvements.


Mod_python mailing list
Mod_python at modpython.org

More information about the Mod_python mailing list