Datasheet

Part I: Introduction to Python Frameworks
14
that enables content-based applications to be constructed quickly. The TurboGears team has focused on
the RIA space as a whole and has created a highly pluggable architecture. What this means in a practical
sense is that even though there are reasonable default choices for supporting componentry, substitutions
may easily be made (such as using SQLite instead of MySQL for model representation, or Cheetah
instead of Kid for templating).
Controller Invocation
As suggested by Figure 1-2 , a URL address in the TurboGears framework results in a server-side call to a
method (whose name is a part of the URL) in a file called
controller.py . As you will discover when
you start adding methods to the controller, the method becomes instantly available. You don’t have a
recompile step nor do you have to restart a virtual machine (VM) or the web server layer. TurboGears
provides instant developer gratification.
In Ruby on Rails, there’s a lot of chatter about favoring convention over configuration. Django takes the
opposite approach because it uses a mapping file to map URLs to the controller code. This strategy
decouples the URL path composition from the actual underlying implementation, which in turn enables
Django-hosted applications to maximize code reuse and controller deployment.
JavaScript
Much as Prototype is the preferred JavaScript and AJAX library implementation in Rails, TurboGears
uses MochiKit to create some very useful binding capabilities for form and effects handling. Django
doesn’t really have a demonstrated preference for a JavaScript library nor even a loose binding to one in
particular. As you’ll see demonstrated later in the book, where a project using TurboGears and Flex is
shown, there are no real limits to how the user experience or the asynchronous call-and-response system
is handled.
Licensing
Licensing is always a critical deployment issue. It’s important to know whether you can deploy your
creation unencumbered before setting out to build it in the first place. We (the authors of this book) both
contribute to and strongly advocate the use of open source. Here are some guidelines to help you do
the same:
Because TurboGears is a composition layer sitting atop other frameworks, it can’t be considered
independent of its moving parts. Kid, the default templating engine, is licensed under the MIT
License (
www.opensource.org/licenses/mit-license.php ), which supports full transitiv-
ity with respect to derived works. This means that, basically, you can use it without worry.
MochiKit is dual-licensed under the terms of the MIT License, or under the Academic Free
License (AFL), which is a very tolerant license with respect to the rights to use, deploy, subli-
cense, and distribute derivative works. SQLObject, the object-relational mapping (ORM) layer, is
protected by the Lesser General Public License (LGPL), which is a bit more restrictive. If you
modify the source of the SQLObject library itself, you’ll have to make those changes available to
all. Of course, that doesn’t mean that your derived works are in jeopardy. You can create and sell
them or give them away without concern.
Django, because it was created from whole cloth, is under a single open source license (the BSD
license). This is very generous with respect to improvements in Django itself and makes no
demands on derived works.