TurboGears: Pulling it all together
Python and every other language out there have many choices available for each part of a web application. First and foremost, TurboGears assembles a great collection of tools, packages them for use together and provides information on best practices when used together. Many people have similar needs when developing web applications, and there's a lot to be gained by putting it all together.
Once the pieces are together, then TurboGears starts doing integration between them. CherryPy offers an excellent way to write controllers for a web app, but CherryPy has no opinion about templates. TurboGears does have an opinion: Kid is a great way to write templates. And, by using TurboGears, you get more than you would get with just Kid and CherryPy. Here's an example:
This small example has a few things going on that show off the current main features of TurboGears.
- The "hungry" parameter is guaranteed to be a boolean on the way in, thanks to the integration with FormEncode.
- CherryPy knows nothing about locating templates. Using TurboGears, neither do you... just put your templates in a package near your code, and you can use standard Python package notation to refer to them (as you see in the "html" parameter to the expose function)
- Kid knows nothing about reloading templates in development environments. TurboGears does, and will automatically reload changed templates when your CherryPy configuration specifies that you're working in a development environment.
- Neither Kid nor CherryPy know anything about JSON, but by returning a dictionary instead of a string, you can use any of your CherryPy methods as a JavaScript client accessible API. MochiKit even includes a convenient function for processing a request that returns JSON!
TurboGears also includes a command line tool that can get your project started right away with a "quickstart" and that wraps SQLObject's sqlobject-admin command to make life easier for quickstarted projects.
Take it for a spin
TurboGears is easy to install, despite the number of packages required. It's open source and free to use in both closed and open source projects.
Get going with the Getting Started primer that describes how an application is set up. Or, take the quick tour with the 20 Minute Wiki.