What Makes Pylons Stand Out As a Web Framework

After 6 release candidates, Pylons 0.9.7 final has been released. Big congrats to all developers. Although it's just a point release, I think this is a huge milestone for Pylons for one reason: It has proper documentation! I've been using both Pylons and Django for several web applications and Pylons' old docs were sparse and hard to navigate. This didn't stop me from digging in and playing around with the framework but for a project to really reach a wide audience it needs well-organized, readable documentation. I can think of many well designed, solid programming tools that have failed because, simply, their docs were not readable. There is a difference between having comprehensive documentation and having documentation that is readable. Django got this right from day one.

As a Pylons user, I'd like to point out a few reasons why I like it and some reasons I don't. It's not meant as a fair comparison to Django, but Django is the only other web framework I know pretty well so it is my point of reference.

Likes:

It's a "hacker's" framework. When you install it, Pylons generates just enough code to expose its operational mechanisms but not too much code to make upgrading hard. In other words, the core of Pylons is in the pylons module yet all that initialization and request handling code is exposed to you in your own application.

Pylons is just a wrapper around lots of other modules maintained by the community. Just like Python itself ;) This is an advantage to me because the PyPI has a lot of neat stuff and it's easier to create, test, and maintain a small component that does one thing well than it is to fit that into a large framework that does everything. In the critique I've seen of this feature, I think mostly it was due to a misunderstanding of the setuptools module (and easy_install script), which provides utilities for handling large amounts of dependencies. There is already a nice alternative to easy_install which allows for flat installation of dependencies (no egg directories) and more, called pip. Wrapping up lots of other powerful tools makes for a powerful web framework. Here are just a few of what I think are excellent add-ons to Pylons (or any web framework) : Paste (especially the _debug view; Django should steal that :)) WebOb WebTest WebError SQLAlchemy Nose Fixture

WSGI Middleware At some point in the past I might have marked this as a dislike. WSGI is hard to understand. Admit it, it will make your brain bleed! But once you get it, it is very clever. I have written a lot of custom middleware to do things like intercept URLs to stub out web services, add static file handling for development, and provide custom error handling. Most of Pylons is implemented as middleware so you can literally strip it down to the core if you need extra speed and simplicity. Also, WebOb provides utilities that make WSGI simpler to implement.



Dislikes:

Short variable names and from yourapp.lib.base *. UPDATE : I just found out the import * and short variable names c and g are no longer the defaults in 0.9.7.

: I just found out the import * and short variable names c and g are no longer the defaults in 0.9.7. Sharing applications? I admit I haven't tried to share applications in a Pylons app the way I have in Django. I suppose this can be done in Pylons simply with middleware? Anyway, Django seems to have thought about this problem a little more and makes it easy to "glue together" multiple applications so that their URL spaces can merge effectively.

Routes I don't like Rails-style routes, the default dispatching middleware for Pylons. I much prefer Django's URL patterns which are more pythonic. OK! I guess that means I need to write a Django-style URL middleware :) Obviously it doesn't bother me too much because I have not written my own. UPDATE: In the comments, L.C. Rees posted a link middleware that does this: urlrelay. Cool!



As a disclaimer I should point out that I am one of those developers who likes to build low level tools. I certainly reuse existing components when possible but building small tools that do one thing and do it well is fun because it's easy. Pylons fosters this approach to software. Not all developers are like this and I'd say, overall, Django probably offers more of a "batteries included" feeling.

back