Is Zope the Answer?

9 September 2008 12:29

For writing web applications, I am increasingly convinced that Zope is the best way forward for a large majority of tasks. It's reliable, well-tested, documented, and uses unicode throughout. And it currently has the most appalling website of any framework. So, what makes it so good?


Python rocks. I'm not sure whether I could stand programming in any other language. Everything else is so redundant. Python is simple: I don't have to think about how to code something. I don't need a massive reference manual next to me just for the language itself. It makes me happy. Well, less annoyed, anyway.

So, recursing slightly, what's so good about Python?

Interactive interpreter

Yes, some people still code in languages which require a compile step and which you can't experiment with interactively. Strange, huh? But, web development is usually done using dynamic languages, so what sets Python apart?

Significant whitespace

Your code does what it looks like it does, and it's not littered with curly braces/'end' statements. What are you complaining about?


I really think the single best thing about Python is doctest. Both in docstrings and in separate files, it really makes life much better. It means I write tests which always catch lots of bugs and make refactoring pretty much painless. I often write a doctest as a design document, which makes me think about how I want the API to work before I start writing the code. The code coverage reports from z3c.coverage are the icing on the cake for Python testing.

In the face of ambiguity, refuse the temptation to guess

Python prioritises making it hard to make mistakes without realising it over being able to do things really fast. Well, nearly. Python 3 will get rid of a few more including the ability to compare arbitrary objects (which actually works on memory location). Ew.

Choice of programming style

When dealing with lists I often write in a functional style; when I have complex data structures I write very object oriented code. Python lets me do whatever I feel like at the time. Sometimes all you want is a script with a couple of procedures, and that's all I want to have to write.

So, back to the best of Zope...

Component Architecture

Zope 3's component architecture has lead to a level of cleanliness, reusability and testability of code that I would not have thought possible. The component architecture forces you to think about how your code works, without restricting you in any way. I increasingly notice that I write better code through trying to take advantage of the component architecture. What does that mean? Well, usually it means adding new functionality without modifying existing code at all. How? Use an adapter.

Object Publishing

I have to admit, I really don't get this MVC business for web applications, and I don't see how the standard /model/controller/id url scheme is going to make sense very often. Choosing a URL structure for a site forces it to be made into a hierarchy of some sort, and this fits with having some tree of objects (not all of which are necessarily persistent). I often don't have many views per object, often just a view and an edit view, making my applications really quite ReST-like (which isn't necessarily good, but is fashionable at the moment).

I also like having a separate object created for every view and viewlet; it feels right to me. I guess it is more like multi-model MVC.


zc.buildout is unfortunately quite tricky to get started with, but is well worth a lot of investment. It enables the construction of repeatable environments for development, testing or deployment, without affecting the existing Python installation. How we got by without it I'll never know.


In my opinion, the ZODB is Zope's biggest asset. Change your classes to inherit from persistent.Persistent, use persistent lists and mappings, and that's it. You can completely ignore the problem of data storage. People continue to claim great things of object-relational mappers, and they continue to fail to live up to the promise, mainly due to the fundamental impedance mismatch.

I'm encouraged to see that new tools are under development for making the ZODB less scary, for example a new object browser.

And the bad bits

Okay, so what's not so good? Well, all the experimentation which goes on to develop all these great technologies also leads to a lot of less good ideas, and it can be very difficult to keep ahead and to know which ones to go for. It makes life interesting, but can be pretty frustrating when you just want to get a job done.

Python 3 is probably not that far away now, and is rather scary. There is no significant common subset between Python 2 and Python 3 (mainly due to the change in string type, which will default to unicode instead of raw bytes). What the transition will do to the Zope world remains to be seen, but there is certainly a question as to whether the cost of the change is really worth it.

Finally, Zope uses some C-level code to implement some of its security, which I believe is the sticking point getting it to run on PyPy/Jython/Google App Engine. Hopefully these problems will be navigated somehow. Zope on App Engine sounds like a very attractive proposition!

Leave a comment