October 25, 2005
This article was contributed by Matt Gushee
The hottest new thing in Web development these days is
TurboGears (TG),
a "full-stack" Web development framework implemented in Python with
model-view-controller as its key design principle. Development is
proceeding rapidly: the first public release, 0.5, appeared on September
17, and the product has since gone through several iterations and now
stands at version 0.8a4. It might seem an impossible pace, but
TurboGears is not so much a new product as a new assembly of existing
products. As the project Web site puts it:
TurboGears takes the best components available and combines them
into one easy-to-install, documented whole. TurboGears includes
parts that join the pieces together and make them work together
seamlessly, but doesn't obscure each included project.
The meaning of "full-stack" is somewhat in the eye of the beholder, of
course. But by most standards, TG does a good job of providing
for all tiers of a typical Web application. Its major components are:
- SQLObject
-
an Object-Relational Mapping (ORM) library
- CherryPy
-
a lower-level Web application framework with a built-in HTTP server
- Kid
-
a templating system that embeds Python code in well-formed XML
documents
- MochiKit
-
a rich but lightweight JavaScript library that supports asynchronous
HTTP
requests
Additional components provide support for unit testing, XML document
navigation, form validation, and conversion between Python data
structures and JavaScript Object Notation (JSON). Third-party extensions
have started appearing, too, like the
CatWalk
model browser.
At first glance, TG looks a lot like
Ruby on Rails.
Certainly, the
projects are similar in their goals and high-level architectures. And it
is fair to say that TG is largely inspired by Ruby on Rails--but there
are differences. For example, TG comes with built-in support for
JavaScript Object Notation
(JSON); combined with asynchronous HTTP requests, this facilitates
AJAX
development--or perhaps we should say
"AJAJ"--by substituting a simpler data format for XML.
The templating systems are also significantly different: Kid templates
consist of well-formed XML (often XHTML in practice) with Python
embedded in attributes and element content, while Rails uses Embedded
Ruby (ERuby), which uses non-XML tags to embed Ruby in (X)HTML or other
text files.
One of the most important differences, however, is in the ORM layer: the
ActiveRecord package used in Rails provides an object layer over an
existing database, whereas Python's SQLObject also allows the database
to be generated based on Python objects.
This is not to suggest that TG is superior in every respect. Rails has a
"scaffolding" feature, which automatically generates
CRUD (Create, Retrieve, Update, Delete) operations.
There is also an ActionMailer package which
provides e-mail services for applications.
In other words, while TurboGears and Rails have many similarities,
they are far from identical.
Beyond the differences in features, there remains the highly subjective
matter of language choice. Even if TG were simply a clone of Rails,
surely it
is a wonderful thing that developers can implement architectures in the
language of their choice. Isn't that what open source is all about? And the
community appears to have ample energy for creating and maintaining Web
frameworks.
To my mind, what really stands out about TG is the clear vision and the
sense of competence that its developers are communicating. There are
many technically sound and interesting Web tools available, but they
often suffer from poor documentation and worse marketing. While its
feature set is highly attractive in itself, it is the project's superior
presentation that makes it likely to attract a broad following.
Additional Resources
(
Log in to post comments)