Pyramid vs Django

Although I’ve always been a dedicated Django programmer, I have to admit that it cannot solve every web problem in the world. Django started as a nice, simple, and easy-to-use web framework for python programmers, and slowly matured into a do-it-all-for-you monolithic API. If you’re just starting to program the web, then Django is a very good choice.

However, the power of Django is somewhat limited by its ORM, which is a thin layer above raw sql. Admittedly, Django’s ORM is sufficient for most common website data management work. But its raw power cannot compare to that of SQLAlchemy, which is the de-facto ORM in the python community. In Django, simple things are easy to do, while complicated things are near-damn-impossible to do. In SQLAlchemy, simple things require more preparation than Django, but complicated things are possible to accomplish.

When I saw Pyramid for the first time, I was seduced by the clichéd “100% test coverage”, “clean, small code size of only 5000 lines”, “comprehensive documentation”, etc. I decided to give a try. As soon as I opened the documentation to the first page, I was hooked and read the whole documentation in one day (with a little bit coding along the way). Man, I love this framework. URL mapping can be done by either normal routes or Resource Traversal; ORM is by default ZODB or SQLAlchemy; the application runs on top of WSGI, which exposes access to raw HTTP requests / responses if you really want to tamper the data; testing is done by utilizing nose or any other framework you like; and numerous other clever design. You can develop your website in a truly orthogonal way: one part of the website doesn’t have to know anything about the other part, and they can share the same authentication back-end and common public database models. Suppose your client asked for a new feature on a running website, you can develop the new feature as a separate website, demo it to the client when it’s done, and copy-and-paste / git-submodule the new feature onto the running website without any downtime. With a nginx-based load-balancer running on a front-end VPS, your web application can grow by simply adding one line of configuration to the file nginx.conf and becomes truly scalable and maintainable.

Maybe you don’t believe me, but check out several websites who’re using Pyramid: dropbox.com, digg.com, bittorrent.com, o’reilly.com, opera.com …

In conclusion, I think Pyramid is much more than a mere web framework, but a proved way to organize and design your website modules in a comfortably orthogonal way so that you won’t get a phone call during the middle of the night when the website is down…

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Pyramid vs Django

  1. Andrew Dike says:

    I was thinking of pyramid for a new commercial app i want to build and although a relatively inexperienced programmer, I had similar thoughts. I’ve read write a bit of documentation on both and felt that Pyramid would give me greater flexibility further down the line, especially as I plan on using a nosql database. Thanks for your thoughts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s