| Chris Miles ( @ 2006-06-09 00:58:00 |
| Entry tags: | cheetah, cherrypy, nevow, python, webapp, zope |
Python web frameworks - the double-edged sword
I needed a web application framework for a project with very simple requirements (dynamic pages, no data persistency). Dynamic content will be pulled from an external source as XML. The abstraction of fetching the content from the source and representing as Python objects has already been done. So all I need from a web framework is the simple ability to render some dynamic pages.
The double-edged sword of the Python world is currently the abundance of web frameworks. All of them are good in their own right, but which one is right for your particular job? Here's what I tried for my simple project described above.
try:
Nevow / Twisted
except:
I really like what I've seen of Nevow so far. I've been playing with Twisted for a few months now, and I've used Nevow to build a few test/prototype projects. Along with Formal it is a nice web framework.
What is questionable (at least in my eyes) is how ready for production it is. I haven't put it under any real load, and don't know anyone who has, so I put the question to #twisted.web, "Any performance issues to be concerned about? Let's say, access rate of 100 hits/sec ..." and got mixed responses, none of them giving me confidence that Nevow was ready for busy production site deployment, some of them sarcastically unhelpful, a few of them pointing out the performance bottlenecks to avoid (like the built-in Nevow sequence renderer) and recommendations to use a lot of caching (both within Twisted and in front of) as much as possible.
I was left with the feeling that Twisted/Nevow probably would do the job, as those guys do seem to know what they are doing, and I was keen to continue using a framework I enjoy, but really there were too many doubts and I didn't want to use this customer project as a guinea pig for Nevow benchmarking.
try:
Zope (specifically 2.9+Five)
except:
I have implemented some simple Zope websites in the past (all TTW - "Through The Web") and done some Plone/ArchGenXML development, and I like some elements of Zope, especially the Zope Page Templates.
However, I decided that if I am to use Zope for any new projects (and certainly customer projects) that they would all be filesystem based, not TTW. Fair enough, you say? I quizzed #zope on the best current methods for implementing filesystem based sites in Zope and the response was to use Zope 2.9 + Five (which takes advantage of some of Zope 3's architecture to further separate the implementation from the view from the configuration).
In theory it sounded right. In practice, I grabbed two Zope 2.9+Five tutorials and went through them both. My needs were much simpler than the tutorial examples, so I attempted to strip the examples down to produce a simple dynamic web page which was all I needed to start with. After half a day of screwing around with Interface definitions, XML config files and obscure classes just to output a simple dynamic page, all without any success, I gave up. Admittedly I didn't try to read any of the documentation to understand it properly, but frankly, that is the point. I shouldn't have to. I really wasn't trying to implement anything complex.
I am sure Zope is great for much larger scale projects (as Plone proves) and I'm sure I'd catch on after reading the docs in more detail along with one of the Zope 3 books, but as a lightweight web app environment it ain't even worth considering.
try:
CherryPy
except:
I had considered CherryPy to be a bit mickey mouse in the past, and had never actually used it. However, for the simple needs of this project, I soon realised, mickey mouse is all I needed. I grabbed CherryPy, grabbed the tutorial, and within minutes, literally, I had some dynamic pages up & running. Nice.
The good thing about CherryPy is that it comes with no templating engine - the user is left to choose his own. The bad thing about CherryPy is that it comes with no templating engine... so the next few hours were spent reviewing the current bunch of recommended templating engines. My preference was an XML compliant templating system, along the lines of Zope Page Templates or Nevow's templating system. I had a quick look at Kid but was left unsure about the health of the project - comments along the lines of the project being abandoned, or at least, not kept up-to-date, made me step back with caution.
In the end, because time had really dragged on, and I needed to get this implementation up & running quick smart for the customer, I grabbed Cheetah and ran with it. It has so far has proven itself to be quite flexible and insanely easy to use. I really hate the look of the templates that come out of a Cheetah project, they are ugly as sin. Arguably more ugly than PHP... But I can't deny that it works nicely and is trivial to pick up and get instant results.
finally:
When you need to quickly implement a solution for a customer using reliable technology, stick with the simplest possible technologies. In this case, the CherryPy/Cheetah framework has produced results extremely quickly, has an easy learning curve and good community support.
When you need to build a much more complex solution, then the likes of Zope or the Plone CMS may become more practical. I am certainly keen to learn Zope 3 properly one day, but fear that a good excuse to do so may still be far away.
When you want the best of both worlds, with top-notch technology from a bunch of smarties, Nevow appears to be the solution, and it is my personal favourite so far. However, the Nevow & Twisted community need to learn how to step down and speak to the normal folk once in a while and help promote the quality and reliability of their technologies.