Rich UI Webapps with TurboGears 2 and Dojo Screencast March 31st, 2008 at 10:12 am by Kevin Dangoor
The PyCon 2008 talk videos are making their way up to YouTube. My talk is not yet there, and the footage they’re putting up right now is the “raw” footage from the camera at the back of the room. I have posted a screencast version of my talk, “Rich UI Webapps with TurboGears 2 and Dojo”:
This is basically the same talk I gave at PyCon, but I made a few tweaks to make all of the code easier to follow.
Speaking of the code, you can download the “DumbSurveys.com” demo application to review the code at your leisure and run it on your own computer. The file is 10MB because it includes the complete Dojo toolkit, and I set it up using zc.buildout, so it’s trivial to get it running. Take a look at the README.txt file to get it running.
You can run the sample without the Comet functionality, but if you’d like to try the app with Comet you’ll want some kind of Bayeux server running on port 8001. I used the Twisted Cometd server for my demo.




Posted March 31st, 2008 at 10:14 am
[…] a screencast version of my talk “Rich UI Webapps with TurboGears 2 and Dojo” (note: screencast is now up), as well as a downloadable version of the code. The technique that I show off—having JavaScript […]
Posted March 31st, 2008 at 10:23 am
[…] I have recorded a screencast of my PyCon 2008 talk and put the code for the demo app online. Check it out on the SitePen Blog » Rich UI Webapps with TurboGears 2 and Dojo Screencast. […]
Posted April 2nd, 2008 at 10:49 pm
I tried to click on the link for downloading the dumbsurveys.com example but failed.
Posted April 2nd, 2008 at 10:57 pm
@Domingo, I just tried it and it worked for me. Note that it is a 10MB .tgz, so you might want to right-click, save as …, and see if that solves your issue.
Posted April 4th, 2008 at 3:18 pm
Kevin,
is there a technical reason for using the twisted cometd server instead, let’s say, orbited?
Posted April 5th, 2008 at 7:16 pm
@Domingo: Not precisely a technical reason… Dojo includes Bayeux protocol support, so I figured I’d just use dojox.cometd rather than a separate JavaScript library (which is what Orbited would require).
You can actually use any of the Bayeux servers.
Posted April 8th, 2008 at 12:15 pm
Kevin,
I ve just tried to follow carefully the steps involved in running de dumbsurveys.com demo.
I indeed have installed tg2 from subversion and pylons as of mercurial. With both I can quickstart tg2 projects without a problem.
After buildout , I had to edit myself lib/base.py to import tmpl_context as context instead of plain context. Also I edited decorators.py from the tg2 intstalled under eggs because tries to use a subscript which is empty. After these changes I could start the project with bin/paster serve development.ini , but when opening browser in localhost port 8080 I got an internal error raised by WebError, sort of….
File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/exceptions/collector.py”, line 281, in collectLine
if locals.has_key(’__traceback_supplement__’):
AttributeError: ‘Context’ object has no attribute ‘has_key’
Any hint?
Posted April 9th, 2008 at 9:16 am
Hi Domingo,
From what you’re describing, it looks like there have been at least a couple of changes in WebError, Pylons or TG2. That’s the trouble of working with pre-release software. I’m sure the changes are minor, though.
One thing to note: the tarball included Pylons and TG2 in cache/dist. You shouldn’t have needed to install them. (And, in fact, the buildout shouldn’t use any code that you have installed in your system site-packages directory…)
I’ll take a look over the next couple of days to see if I can change something in the buildout to keep it pegged at the working versions and fix any glitches I find. Obviously, it worked when I did the original demo and when I packaged it up :)
Kevin
Posted April 9th, 2008 at 10:32 am
Kevin,
every module included in cache/dist was copied by buildout to eggs directory . All of them but TG2 and Pylons. I don’t know if buildout had a problem with that, because I had already recent versions of TG2 ( svn ) and Pylons.
Tks :)
Posted April 9th, 2008 at 7:53 pm
Hi Domingo,
I just downloaded the tarball that’s attached to this blog post and running bootstrap.py followed by bin/buildout worked just fine.
Can you try changing the buildout.cfg file so that the list of eggs looks like this:
eggs = TurboGears2 ==2.0a1dev-r4169
Pylons ==0.9.7dev-20080311
FormEncode <0.9
PasteScript
TurboJson
I think what’s happening is that the buildout is indeed finding the TG2 and Pylons versions you have installed. So, this config change will peg the version numbers at the ones in the cache.
Posted April 9th, 2008 at 7:57 pm
p.s. make sure that the lines after the “eggs =…” line have leading spaces.
Posted April 9th, 2008 at 9:00 pm
Kevin,
it worked!
All was about editing buildout.cfg as you suggested.
Tks a lot!
Posted April 10th, 2008 at 4:30 am
Great! I’ve just updated the sample code to have the new buildout.cfg file. Also, using Peter Higgins’ recent “dojo-mini” post as a guide, I’ve reduced the size of the tarball from more than 10MB to 1.8MB.
Posted April 10th, 2008 at 2:40 pm
Kevin,
it would be great if you can add to the README file instrucciones on how to install the twisted cometd server because is not that easy. It needs twisted svn because depends on web2 submodule which is not installed via easy_install. Indeed I have some trouble to make it run right now.
Posted April 10th, 2008 at 6:40 pm
Yeah, Twisted and easy_install don’t seem to play well together yet.
What I ended up doing was using virtualenv and installing everything into there. I’m not sure that I have any great advice for installing that package at this point (with some work, the installation could be automated, and that would be a better solution).
Note that any Bayeux server should work fine. I happened to use the Twisted one, but it’s possible that one of the others listed here:
http://cometdaily.com/maturity.html
may be a quicker install for people who don’t already have Twisted and lxml set up.