Thursday, July 21, 2005

Python Web Application Frameworks : Django and Subway

I've been looking around for a long time now for an application framework I can use to speed up my web development. At the beginning I was reimplementing all six wheels on my wagon but eventually realised that if things were to get any better, I'd have to build on what others have done.

After much searching and investigating I've found two interesting projects:

Django looks to be Python's nearest challenger to the over-hyped (IMHO) Ruby On Rails. Despite many nice features and a wonderful automatic database admin system, it also suffers many of the problems I see with Rails. The very features that make it look great in tutorials (or fancy videos) are the ones that make it infeasible for complex site development. In the beginning it's lovely to be told where to put your source files, or how to add simple authentication to your site. When things get tougher this these frameworks seems to become heavy weights getting in the way of what you need to do.

On the plus side, Django's template system includes many features that I had not seen before. Simple little things like a "cycle" tag that easily allows changing classes for alternating row colours are a great idea!

Subway is an effort to merge some powerful low-level tools (most notably CherryPy, Cheetah and SQLObject) into an easy to use high-level framework.

I had already looked at CherryPy quite a lot, and based my current development on it (a sports team organisation site). It's a great low-level framework that stays out of your way well. Coupled with my own integration of Cheetah, SQLObject and a home-grown forms library it was going well. Problem was, it wasn't very scalable and there were many things I felt I was lacking (especially in the template departement).

Subway makes the Cheetah integration as perfect as it can be. It ties in FormEncode very nicely and makes the whole lot just work.

Unfortunately, my application wants more. I've long been thinking about a template system that knows about the cachability of each part that makes up a page. Cheetah's compilation system is nice, but seem out of place after using them a while. I don't really need the timesaving that pre-compiling gives me, I need to be sure most of the webpage that will be served a thousand times isn't re-rendered at all, but just thrown out from a buffer.

So, regrettably, I've written my own template system. Fortunately to get to a working solution only took a couple of days part-time, and now I have a framework in which I can all all the caching cleverness that I need, plus all the lovely tags that I found so appealing in Django.

I'm now left with the dilema - am I using Subway at all now or should I go back to CherryPy raw?

No comments:

Post a Comment