Other projects used by TurboGears

When you download TurboGears, you get several packages in the bargain. Though the four main packages are the ones you'll interact most directly with, these other packages are also working behind the scenes and available for your use to make your life better.

ElementTree

For anyone who's ever had to write code to the W3C interfaces in Java, you know how difficult working with XML can be. ElementTree provides a programming interface that is far easier for common XML tasks. It is not the be-all and end-all XML library, but it's a very practical approach to much of what you'll need to do.

TurboGears also includes cElementTree, which is an implementation of the ElementTree API in C. cElementTree is very fast.

Kid uses ElementTree to parse and work with your templates.

Here's an example of ElementTree usage from the ElementTree site:

FormEncode

When data comes in from the web, you get a blob of strings that map to whatever was on the form the user submitted. Odds are that what you'd like to have is something different. Perhaps you want a boolean instead of the string "True" or perhaps you want an int instead of the string "42". Or, maybe you need to verify that the user entered "301-555-1212" for their phone number (let's ignore the usability issues of that, shall we?).

FormEncode provides a framework for converting incoming values to their appropriate Python versions and converting Python values to whatever is needed on the other end. In the process of doing the conversion, it also makes sure that the values are valid and provides a means to describe what the problem is.

FormEncode is used by SQLObject to do conversions to and from database types. You'll also encounter it in TurboGears directly when using the validation feature.

Here's a quick example of using a form encode validator:

>>> import formencode
>>> from formencode import validators
>>> validator = validators.Int()
>>> validator.to_python("10")
10
>>> validator.to_python("ten")
Traceback (most recent call last):
    ...
Invalid: Please enter an integer value

Nose

Python's standard unittest module is based on the venerable JUnit. It's a straightforward framework, but there are some usability niggles here and there.

For example, it's pretty common to have a TestSuite that covers your whole project. It's a good idea to run the full TestSuite frequently. Unfortunately, you have to keep that suite up-to-date by hand. TestGears provides a simple means to gather up all of the tests in your project. With nose, you can just run "nosetests" to gather up all of your tests.

Even though writing a TestCase is easy, sometimes even that is more overhead than you really need. With Nose, if you put functions with names beginning with "test" in a file that begins with "test_", your tests will run automatically as part of the suite.

json-py

JSON (JavaScript Object Notation) specifies a way to represent data as nested hash tables, lists and simple values. For transmitting data to a browser for further manipulation, JSON has some significant advantages over XML: the syntax is native JavaScript so it's fast, can be interpreted directly via eval() and is supported equally by all browsers.

The json-py library provides conversion routines to migrate simple values from Python to JSON and vice-versa.

Download Stable Version

TurboGears 1.0.4.4

Mar 7, 2008

Latest stable version

1.0.4.4 is a bugfix release. It is still recommended to upgrade as it fixes a problem with the cookie handling and adds some more control about the redirections for login. Please consult our changelog for all the details.
Download now button Upgrade instructions button (Upgrade hints for SQLAlchemy)

Community

Advertisement

Rapid Web Applications with TurboGea...

Mark Ramm, Kevin D...

  Buy New $29.69

Privacy Information

Hosting Options

TurboGears can be hosted in many places, but we've got some of the best choices picked out. Super simple TurboGears use from WebFaction starting at $7.50 a month or, if you need more control, dedicated servers from ServerPronto starting at just $29.95 a month. Check it out
last updated: Jun 25, 2007
Comment on this page
s