• Could not connect to Twitter

Choosing a Python Web Framework I - bottling it

A few years ago, when choosing a Python Web-framework with which to build Showmedo, life was a little simpler. The big CMS frameworks like Zope and its relatively user-friendly little bro Plone were reasonably well established and there were a few up and coming lighter frameworks, which promised to take one closer to the Python. Standouts here were Turbogears and Django.

I tried using Plone, even bought the book, but found it very unwieldy. Like so many frameworks it was perfectly happy until one wanted to do something outside its workflow plan. Then things got icky, really icky. There was also far too much ‘magic’ going on, and far too little connection with the underlying Python. After this experience Turbogears was a breath of fresh air. I could build a web-site in Python and leverage all the efficiency and elegance of the language up close and personal. What could be sweeter? I enjoyed the experience so much I didn’t give Django a fair crack of the whip. Although back then it was in beta and had been postponing a 1.0 release for a very long time.

Well, time moves on, and if there has been anything as intense as a framework war, it’s fair to conclude that Django has taken the spoils. Which seems fair. It’s a fantastically managed project, the documentation seems top notch (very important point), and the community is huge, enthusiastic and growing. For a more flexible experience Pylons is threatening to steal some of Turbogears thunder, offering a more modular, ‘best of breed’ alternative to Django. One of the big advantages here is the possibility of using the superb and acknowledged king of Python ORM database libraries, SQLAlchemy.

Anyway, today I come to praise something at the other end of the spectrum and newish to the field, namely Bottle.py. An entire web-framework packaged in a single Python module, which seemed crazy when first I heard of it. Bottle bills itself as a micro-framework, fast, simple and lightweight. Having had a chance to play around with it, I can testify to this. It makes a superb development server, among other things. After previous battles with Zope/Plone it’s pretty incredible to get a server up and serving pages in a few lines of Python, with one imported module. Here’s the ‘Hello World’ example:

from bottle import route, run

@route('/:name')
def index(name='World'):
    return 'Hello %s!' % name

run(host='localhost', port=8080)

So, if you fancy getting away from the complexity of the bigger frameworks and getting back to basics, Bottle.py is a great option and an amazing achievement.

In the meantime, a little selection of Python web-framework videos from the Showmedo vaults:

Eric Florenzano’s humungous series, Django from the Ground Up.

Jiang Xin’s Pylons series.

Kevin Dangor’s Ultimate DVD Turbogears set. Note: Turbogears 2 has seen some impressive changes to the framework, but much of Kevin’s presentations is still applicable.

We don’t yet have a bottle.py screencast, but there will be one soon. In the meantime, the closest to low-level web-appery we have is John Montgomery’s introduction to Python Web Programming CGI
. Note: this is a club series but the linked introductory video is free and gives an overview.

Please share:
  • DZone
  • del.icio.us
  • Reddit
  • Furl
  • Ma.gnolia
  • email
  • StumbleUpon
  • Technorati
  • TwitThis
  • Slashdot
If you enjoyed this post, make sure you subscribe to my RSS feed!

Related posts:

  1. New series – Agile Python+Pylons to build pySvnManager
  2. Learn Google App Engine with ShowMeDo
  3. Introduction to Python web-programming: CGI
  4. Setting Up a Django Development Environment
  5. Choosing a Python IDE

Comments are closed.