Getting started with TurboGears

Actually I did the The 20 Minute Wiki some months ago, so I skipped it even if I’ve forgotten half of it. I decided to begin with Brian’s TurboGears Tutorial.

Requirements

I already had Python 2.4x and EasyInstall installed, so the only thing missing was the latest version of TurboGears. A single line installed the 0.9a6 version:

easy_install -Uf 
http://www.turbogears.org/preview/download/index.html TurboGears

Missing from the tutorial was that docutils (install with easy_install docutils) seems to be required in 0.9. I also installed Python interface to SQLite 3. Can’t be much easier than that.

On with the tutorial

The tutorial consists of building a model, generating database tables from the model, using the built-in interactive shell to add/query data to/from the database, adding some logic to the controller, fiddling with templates and calling the controller from the page. I skipped the AJAX-part for now.

Amongst the things that impresses most with your first TurboGears tutorial is that there are some handy tools that works out of the box, like generating tables from the model and starting the web server. Both single line commands that you just run from inside your project folder. So far the controller or the templates didn’t really enlighten me. Probably because the tutorial was so basic. Mapping between the page and the controller doesn’t at least require any xml-configuration as in most Java web frameworks (some can be replaced with annotations in Java 5), but I don’t yet know if this this is a good thing in a bigger project.

Another nice thing is how easy it is to do for example one-to-many relationships.

Conclusion

Overall, getting started with TurboGears is much easier than with any Java web framework I’ve used. This is not a very kind comparison, since I haven’t used any of the lighter Java web frameworks. Just the most most popular ones (Struts, Webwork2, JSF).

Setting up a JSF project with my favorite IDE IDEA would include automatic generation of a skeleton project and installation of MyFaces. I would manually add Hibernate (or iBatis), a web server, an Ant script for various tasks (like regenerating the database from the model) etc. I guess it might have taken about 4 hours. All this came free with TurboGears. So for a newbie, the initial setup is more than ten times faster with TurboGears I would guess.

Do I like TurboGears yet?

Setting up a project from scratch is still a very small issue compared to developing the product, so I don’t count this as a big advantage.

I am impressed with the out of the box console and how easy it is to define relationships in your model.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: