Framework shootoutΒΆ

Tags: europython, europython2006, plone, django

There are four different frameworks being presented. Every one is given 20 minutes to demonstrate, code and speak to give the audience a feel for the possibilities

  • Turbogears
  • Django
  • Zope (3)

I'm not going to type in everything everyone is typing in at top speed into their editors. I'll just limit myself to some things that made me wonder, gawk with awe, shudder with horror or whatever. It's just my impression, not a quality assessment of the framework in question.

Kevin Dangoor - Turbogears

Kevin has a macintosh 12 inch laptop and uses the "textmate" editor. He'll create a wiki for us.

Kevin dives right in and has turbogears generate a directory with a project skeleton for him. What looked strange to my ZODB-trained eyes was that he was basically defining database tables and columns. He defined it using some fancy sql-to-object mapper (ActiveMapper), but that's still defining SQL tables to me. Man, I'm spoiled with zope's object database :-)

He starts off on a template and that's html sprinkled with '{&'-like constructs. He said at the end of his earlier presentation that he saw no value in xml-based templating systems, but apparently tastes differ. I kinda like zope's tal/metal templating system that uses html constructs and uses attributes to add functionality to them:

  <ul tal:define="results context/getWeblogEntries">
    <li tal:repeat="result results">
      <a href=""
         tal:attributes="href result/getURL"
         tal:content="result/Title" />
    </li>
  </ul>

Ah well :-)

In one of his edit forms he had a very handy autocompletion if you start typing a value previously known to the system. That looked pretty OK.

My impression: you've got to get to know it a bit, but it isn't that big. It looks fine. You can produce good websites with it. Elegant.

Simon Willison - Django

Simon has a 15 inch macintosh laptop (looking at the speed of the thing, probably a macbook) and also uses textmate .

See also the summary of his earlier talk .

During reheasing for this shootout he soon discovered that live coding wasn't something for him, so he prepared some parts for copy-pasting. That way he can give us a better idea what Django is up to. Simon also tries his hand at a wiki.

When running in debug mode, django gives you a rich amount of debug information if there's an error in your application, which helps to to quickly spot errors. Django sure restarts/reloads/whatever FAST. Compared to restarting a plone site... Real Fast.

Simon is a big fan of using django's capability of using base templates, which gives his pages a bit more layout. It's not the huge amount of user interface stuff that plone gives you out-of-the-box, but it solves the same issue of getting a good starting point.

Handy: you can create custom template tags to make your templates shorter. It is a bit comparable to zope's template macro mechanism, but as it uses python code behind the scenes it has a very nice ring to it. It might be more powerful.

Philipp von Weitershausen - Zope 3

Philipp uses a 15 inch macintosh laptop. The editor is mighty Emacs.

He's not going to create a wiki, but he's going to show off what zope3 is good at.

"Zope2 was the Ruby on rails, django, turbogears of 1998." With the exception of using the whole object publishing idea that zope used. It is successful, look at Plone.

Zope3 is a complete rewrite, especially aimed at serving python developers well and to play well with others. It is aimed at tackling complex problems. It uses a component architecture.

There are a lot of existing components. Persistence, templating, i18n, sessions, cataloguing, forms, workflow, etc. To create an application you're going to glue together components (without having to change the existing code) and code a little bit yourself.

URLs in zope are build by traversing objects. Many objects can be treated as filesystem folders that way. That's something very different from the regex url-to-method mappers from turbogears and django.

Philipp creates a new zope product and defines a new folder traverser by subclassing from ItemTraverser, something that, when traversing to test, grabs the item witht the id test from a dictionary. He makes sure that it lowercases the ID you ask for and that it lowercases the list of items in the folder: you can now easily handle WikiNamed files.

To tell zope about his new class, Philipp adds a configure.zcml and registers the new traverser. After adding a file to the folder he could call it whether he asked for test, tEst or TEST.

Restarting zope is slow as usual.

The second part of the work is to create an adapter for ordinary simple documents that detects WikiWords. Couple of lines of code, register it as an adapter, finished.

So Philipp took a normal folder and changed its way of handling content IDs (case insensitive). He also adapted the build-in simple document to allow wikiwords. All without modifying the original stuff. Great for reuse.

Panel discussion

We had some time at the end so it was time for a panel discussion . Q: "Turbogears:What about releases? There are two different betas or betas out apparently". A: We need some more documentation

Q: "Which approaches do you want to steal from eachother?" Django: Turbogears has a nice quickstart. Zope3: zope has nailed the the complex stuff right on the head, but getting started is hard, that's good in django and turbogears. Django: we want to steal zope3's permission system.

Q: "turbogears and django look much the same to me Turbogears: more of a philosophical difference, turbogears is more geared towards reusing existing components. (And no, he's not comfortable in telling people to use turbogears instead of django. Matter of preference.) Django**: They occupy many of the same places, it is mainly a taste issue, where are you comfortable.

Q: "Did you try interoperating?" Turbogears: we tried some django stuff that looked good, but it wasn't really documented. There hasn't really been any usage of eachother's components. Some of the external components that turbogears uses are also used by django.

Q: "Spitting out different formats? Especially json/ajax instead of plain html" Django: We're using a template engine, there's no reason why we can't export what ajax/javascript/jason wants. Turbogears: Likewise. Django doesn't do anything with ajax (except in the admin stuff), that's outside. Your templates can do it, though. It is open. zope3: Of course you can throw another adapter at it. There's already a json adaptor for json requests that does most of the work.

Q: "Any chance of merging django and turbogears in a year's time?" Django: I think not. Turbogears: perhaps some interoperability using WSGI, with part of the website handled by turbogears, part by django.

 
vanrees.org logo

Reinout van Rees

My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):