I believe that Python should be dominating in the LAMP arena. But, frankly, it is lagging behind terribly. I’m not saying that it’s lagging behind in its usefulness and usability, but in the breadth of its adoption.

There are some excellent tools (such as SQLObject) as well as some fantastic web frameworks (such as CherryPy) which make developing web applications faster, easier, and more fun. Python as a language has every conceivable facility available to it to empower web development. The syntax is extremely clean and nimble. It is OO, but not demandingly so. It has a wealth of re-usable code in the standard library specifically geared to facilitate web development.

Ian Bicking wrote a really great article/blog on this topic I guess a few months back. Ian could not have been any more correct with his premise of fixing Python’s web programming problems being the most important thing we can do to market Python. In that article, he stated

We also need input from people trying to do commodity Python hosting, and we need to pay attention to what they say.

In that vain, let me recount my most recent web development experience. (Let me first of all say that I’m not a web developer by trade. I piddle and I hack, but it’s not my day job.) I am in the process of creating a website for my wife. Initially, it was going to be just plain HTML. Then, it was going to need some file-upload capability. Now, it’s going to need user management, a shopping cart, a product catalog, etc., etc.

I initially started just creating plain HTML when that’s all it needed. There was no need to over-engineer, right? Next, when she wanted a file-upload section, I reached for Python CGI. That should do the job pretty simply. Then, as we faced further scope creep, my heart reached for TurboGears, but I knew that wasn’t an option. Not on my hosting plan, anyway. So, I reached for PHP. (And, by the way, I’m not altogether dissatisfied with it, either. But I’ll save that for another day.)

Why did I reach for PHP rather than something Python-based? I can’t believe that I’m so different from everyone else. I believe that this experience (and the answer to the question which I just posed but haven’t answered yet) may shed some light on the current Python situation. I didn’t try Python any further than Python CGI because Python CGI is the most ubiquitous Python offering in the web hosting space; any other options are very sparse.

Let me outline the 3 general options for depoying Python web applications. 1) Standalone processes. Turbogears which sits on top of CherryPy require a standalone server in order to run. They don’t integrate nicely with Apache like PHP does. Actually, that’s not entirely true, but I’ll get to that in a second.

2) CGI. This is by far the most available option for commodity web hosting. But I don’t believe it supports sessions out of the box. You could probably contrive something to stuff a “?PYTHONCGISESSIONID=12ASD83234JALJSDF879S87DF98SA7DF987″ string at the end of every URL and store session data in a database, but that just feels nasty.

3) mod_python. This is currently, IMHO, possibly the best option for Python web development using commodity hosting services. I’ve even read that you can deploy CherryPy and TurboGears in it. But the availability is just not there yet. Google sometime for “mod_python web hosting” vs “php hosting” and you’ll see what I mean.

To sum things up, after failing to find more than a handful of hosting services who would support Python hosting in a configuration suitable to me, I chose a more commonly available technology: PHP. The hosting is cheaper and if I run into a problem with a hosting service, I’m not stuck with a bad host. I suspect that the majority of Python web application development takes place in one of two settings: 1) large deployments where the developer/customer have full access to the boxes they are deploying to, or 2) small deployments for either in-home use or on an intranet where the developer is using a spare Linux box and has full access to it. That’s just a guess, though.

I really don’t have a solution, merely my experiences and an observation of the current state of things. I don’t know how Python will gain a ubiquitous commodity-ready hosting solution overnight. Or, how it will take what appears to be a commodity-ready hosting solution (such as mod_python) and make it ubiquitous. I can’t help feeling that I’m missing something obvious, here, though.