Brian's TurboGears Tutorial
posted by brian at 03:58 AM
This weekend I decided to write my own TurboGears tutorial instead of working on Merquery. If you're interested, check out Brian's TurboGears Tutorial. The application demonstrated in the tutorial can be played with on my server and downloaded*.
Why my own tutorial?
First off, last week I gave a talk on Web Programming with Python, and I never made the demonstration code available to the attendees. Hopefully this will make up for that. The application is the same as the one I made from scratch during the talk, except not crappy.
Secondly, I've made a dozen or more TurboGears apps now and I know how the routine goes. I've also walked a couple beginners through the basics in person. I generally do things in a specific order and this tutorial reflects that.
This tutorial's goal is to give beginners a good understanding of how every basic component of TurboGears works. That means SQLObject, CherryPy, Kid, and MochiKit.
For one thing, it slightly annoys me that the Identity login stuff is plastered all over the default code (okay, just in two places) in 0.9. If it were two lines of code to add that stuff, I'd be okay with it. But as it is, it just looks confusing to newbies. When absolute beginners encounter that stuff in controllers.py and master.kid, I just tell them "Aw, wipe that crap offa there!"
And as soon as you start throwing around any remotely abstract-sounding terms like SecureResource, WidgetValidator, IdentityManagement, DataController... what pops into my head is this thing you may have heard of, starts with a Z.
So yeah. This tutorial starts the reader off with a clean slate, trying to explain all the little things TurboGears does for them along the way. Here's that link again.
* Note: setup.py sdist needs to grab everything in templates/ and static/ by default for TurboGears projects. I just made the archive myself because it was easier than figuring out how to do it with setup.py.
Comments
It's not too hard to make your own new project template (though I don't know if tg-admin makes it easy to use a new template -- but the underlying paster create does). Maybe it would be useful to write such a trimmed-down new project template, perhaps as an alternate starting point to include with TurboGears.
just read your tutorial, I wanted to complete your example step by step, but when I ran "tg-admin sql create" there were always an error: "ImportError: No module named sqlite". what's the problem? I have added "sqlite3.exe", "sqlite3.dll" and "sqlite3.def" into the Python's path( in PATH ). The config line int "dev.cfg" is:
sqlobject.dburi="sqlite:///C|/workplace/bduse/tutorial.sqlite"
why?