Quantcast

Python Steps Up In Django And TurboGears

Get the WebProNews Newsletter:


[ Business]

IBM presented a two-part series on developing applications with Python, using Django as the framework in one example and TurboGears in another.

I’ve been an IBM fan for quite some time, but even more now that I cover them on occasion on different topics. Their people are smart and enjoyable to chat with on topics like search, and they do very well when it comes to finding third party folks to discuss topics as they do on their developerWorks tutorial series.

The two-part discussion presented by Ian Maurer, Senior Consultant, Brulant, Inc, covers Python in a couple of contexts. First, developers working with the Python-powered Django framework to build web applications can build it in Linux and get to work right away.

Maurer goes through the process of the install in his tutorial, and configuring the admin tool for Django. Then the developer can create a model (Django follows the Model-View-Controller architecture) for the project. From Maurer:

Django comes with its own object-relational mapper (ORM) library that supports dynamic database access through a Python object interface. The Python interface is very usable and powerful, but you are also free to drop down and use SQL directly, if needed.

The ORM currently provides support for PostgreSQL, MySQL, SQLite, and Microsoft SQL databases.


Maurer’s Django example proceeds through the development of a job search application. He makes an important observation about templates in Django: “The Django template language has been designed with limited functional capabilities. This limitation keeps templates simple for non-programmers and keeps programmers from putting business logic where it doesn’t belong, the presentation layer.”

Maurer followed up the Django walkthrough with a tutorial on TurboGears, a Python-built mega-framework. This project focused on building a shopping application.

He called TurboGears a mega-framework because of the components TurboGears brings together:

MochiKit: JavaScript library
Kid: Templating language
CherryPy: Base Web framework
SQLObject: Object-relational mapper (ORM)

After installation, Maurer shows how to get started with a model package called tgcommerce. With this, the developer has a simple shopping cart for the application.

Once the model has been created, developers can use CatWalk from the TurboGears toolbox to quickly create, update, and delete data for their model through a GUI.

Maurer found that the error handling in the controller methods could be better. Refactoring in the controller class can catch a SQLObjectNotFound error and make it a NotFound exception. Instead of the 404 error, that could be written to redirect instead.

He also included an Ajax example that adds an item to the cart; “To make this shopping cart example buzzword compliant,” he wrote.

After going through the tutorial, he compared the Django and TurboGears frameworks. Maurer said both were extracted from existing applications and released as open source. Then he summarized the differences:

The different backgrounds of each project have led to different project priorities.

The Django team, coming from the high-demand, fast-paced world of online journalism, has focused on a framework that allows content-based applications to be constructed quickly and modified easily.

The TurboGears team, with its consumer-product foundation, has geared itself toward rich client applications and a pluggable architecture.

Add to Del.icio.us | Digg | Yahoo! My Web | Furl

Bookmark WebProNews:

David Utter is a staff writer for WebProNews covering technology and business.

Python Steps Up In Django And TurboGears
Comments Off


Top Rated White Papers and Resources

Comments are closed.

  • Join for Access to Our Exclusive Web Tools
  • Sidebar Top
  • Sidebar Middle
  • Sign Up For The Free Newsletter
  • Sidebar Bottom