Web Development with TurboGears and Python
rdelon writes "TurboGears was previously mentioned here as "Python on Rails". It has since made tremendous progress and is now a popular Python web MVC framework (along with Django). IBM developerWorks just published a great article about TurboGears and a book is on the way. Unlike Rails and Django, TurboGears is made up of several pre-existing subprojects. One of the great features of TurboGears is the 'toolbox,' which allows you to configure and check various aspects of your application and database in a browser."
Excellent! For those who (like me) can't decide which Python web framework to pick and learn, this is a two-part series on both Django and TurboGears from IBM, one can learn the basics of each one and decide.
python>>> q="'";s='q="%c";s=%c%s%c;print s%%(q,q,s,q)';print s%(q,q,s,q)
Both TurboGears and Django are excellent. Furthermore, each has strengths for different kinds of projects, with TurboGears at its best for web applications and Django for big, industrial strength web content sites. Twisted and Zope are great too, but for most developers, Django or TurboGears is going to suit them best. Both are under rapid, well coordinated development and are proven solutions that will scale well over time. TurboGears' best of breed component approach is, in my opinion, a winning strategy, especially in the Python community since Python is blessed with so many great projects (some people think too many projects), giving a plethora of high quality, well maintained and best of breed components for TurboGears to choose amongst. There are multiple good tutorials on both frameworks here, http://www.awaretek.com/plf.html , as well as related podcast material about TurboGears and related Python material.
The article was interesting, but I disagree with their claim that, "TurboGears is more community-driven than Django because it was built with pre-existing, open source components." From everything I've seen, Django has a strong community behind it. I don't think I've ever seen an open-source project whose maintainer is as helpful to users and contributors than Adrian Holovaty is. He's extremely respectful and responds quickly to bug reports and suggestions. In addition to its clean, unified feel, the community is one of the main reasons I was attracted to Django.
Just the other day in the Ruby for Rails review thread, someone was saying:
Soon to be obsoleted by Airways for Python
Guido Van Rossum heard exclaiming that he was developing with SNAKES on a PLANE
FYI Guido van Rossum prefers Django (from his blog).
And people that use web frameworks in Python will probably be interested in WSGI 1.0 (the Python Web Server Gateway Interface) that will be added to the standard library in Python 2.5: it will probably be supported by all the major Python web frameworks.
There's a hidden treasure in Python 3.x: __prepare__()
I've been using Python for scripting glue at work for about a year now, but I recently had a small side project come up that was better served having a web interface to a database. Like everyone else, I downloaded/installed Rails. I had given Django a peek, but given that this is a side project, I didn't have the time nor energy to keep up with a rapidly developing platform. Django's website cautions about framework upgrades until 1.0 when the base API will be locked, so I went with Rails. Other than learning yet-another-scripting-language, using Rails (without even really understanding it) hasn't been much of an issue.
Choice is both good and bad, in my opinion. It sounds like TurboGears and Django specialize in different things, when it would be preferred for occasional users like myself that there were one clear winner that was evangelized and well supported for all applications. Perhaps out of this competition this will happen for both platforms -- this is where choice is good!
One excellent Python project that doesn't get enough publicity is my favorite ORM tool by Michael Bayer - SqlAlchemy http://sqlalchemy.org/. Think Rail's ActiveRecord with Hibernate power.
There was some talk of integrating it with TurboGears to create some competition for SqlObject. Not sure where this stands currently.
From a quick glance it wasnt apparent how this is licensed.
---- Booth was a patriot ----
In an attempt to combine all the best of web frameworks into one event, I interviewed Adrian Holovaty of Django on the Ruby on Rails podcast: Adrian Holovaty on the Rails Podcast He's a smart programmer and it helps to see the different philosophies behind the way popular web frameworks were constructed.
How did you get from Guido's statement that "Django's gaining steam" to your statement that "Guido prefers Django"? Prefers it over what? Is that from your personal communication with him, something he said in public somewhere else, or are you reading something into that blog posting that I can't see? He doesn't mention anything about TurboGears or his preference in web frameworks, he simply states that Django is gaining steam in a big way. You're jumping to conclusions if you think that blog posting implies that he preferrs one web framework over another.
I'd be interested to know what Guido thinks of Zope, since he worked for Zope corporation in the past. And what he thinks of Zope Page Templates, since he worked on that code.
-Don
Take a look and feel free: http://www.PieMenu.com
While the article mentions Catwalk (toolbox app to set up initial database objects) it does not mention some of the very nice new features in Turbogears 0.9a6 (supposed to be real close to 1.0 now):
- Identity Management
- Widgets / Forms
- Internationalization support
- Optional support for SQLAlchemy instead of SQLObject
The newly added toolbox offers the following tools:The turbogears quickstart can now create a set of customizable standard classes to handle standard authentication and authorization. A User Group Permission model coming with easy-to-use identity decorators for exposed methods. ( Identity Management Documentation )
A system to create reusable Form Widgets (with optional scripting / styles) and to use them in forms -- including support for error display and data retention.
Database tool meant to ease the creation of initial data. Sure, you can always just use plain SQL to set them up, but managing relations between tables can be slow and bothersome, especially for N-to-M relations (RelatedJoins in SQLObject terms)
Toolbox tool helping to design your models. (Showing diagrams etc)
Allows browsing through all available Widgets with working examples, example code and configuration help
Tool to collect internationalized strings and create new language catalogs
I started playing around with Turbogears some time ago and like it very much. The documentation is a bit thin at times, but the source code is easy to read and accessible (using ipython to interactively explore things also helped a lot.) I implemented my blog in python and had only minor problems. And the code size also turned out to be relatively small.. For the metrics fetishists:
Blog with tagging, User handling (subscription, email confirmation etc), Image handling (upload, admin, thumbnails), atom feeds (general + tag based feeds) plus some minor things:
- python code : 1181 lines, 40762 bytes
- kid templates : 610 lines, 21200 bytes
plus some style sheets, javascript code and images..while (!asleep()) sheep++
One of the most appealing aspects of Turbogears imho is the work to supersede the db layer, currently SQLObject, with SQLAlchemy. The problem with most web frameworks is that their ORM db layers treat the db as just an object store, rather than as a relational database. This works for relatively simple 37signals-esque websites, but not for more complicated sites that require a relational algebra engine, for example any relativley complicated web-based BI application or booking engine. For example, one of the fundamental features of the relational model is that the result of any query against a table or number of tables is another table. In that respect, SQLAlchemy lets you map classes not just to tables, but also to joins, unions, and subqueries (which are themselves tables). Turbogears is the only framework I know of so far that is attempting to integrate SQLAlchemy. They're still in the relatively early stages of the integration, it seems, but are working to provide an easy migration from SQLObject to SQLAlchemy when the latter is ready, making TurboGears top on my list of webframeworks to consider/recommend for new projects.
Flying is easy, just throw yourself at the ground and miss. -Douglas Adams
Guide van Rossum writes :
So no, he doesn't prefer Django. It's official: he makes no endorsement whatsoever, except for the low level WSGI standard. He's using Django for at least one application, but he encourages people to compare and contrast all web frameworks.
-Don
Take a look and feel free: http://www.PieMenu.com