newbie: Zope

Martijn Faassen m.faassen at
Fri Sep 1 16:20:08 CEST 2000

Nick Trout <nick at> wrote:
>> Note that questions about Zope belong better on the Zope mailing
>> list.

> Point taken, I will try and join. Wish there was a news group, much better!
> Had trouble getting on the site earlier but now looks okay.

>> What about the Zope Guides?
>> And of course there's the Zope Documentation Project's site:

> I find them a little too low level and sparse. Yes they introduce you to the
> concepts but when you want to actually do something the best I have found is
> a Quick Reference. There is hardly anything on the Document Project site!

The idea of the ZDP site is to help fill it. :) I believe there's also a that may be helpful.

> I like lots of examples. Even the How-Tos are a bit sparse and a little
> obscure for beginners.

There are some very good Howto's out there, it's just a bit difficult
to find them...

>> I'm not quite sure if that information is available somewhere, or
>> whether it's mostly folklore. Lots of ZClasses don't have a base class
>> though. Often also they inherit from Folder or ObjectManager, to get
>> folderish behavior.

> Why, what, how?! What behaviour would this give etc...?

ZClasses without any base class (at least explicitly) can be used to
store some simple properties. I believe the example in the developer's
guide mentions a CD listing; each instance of such a ZClass would be
a CD object. Folderish ZClasses could be used to organize your site;
one way to do this in Zope is to put common methods in the root folder
of the site; subfolders acquire this information. This does pollute the
root folder, though, so another approach is to use a ZClass that behaves
like a folder but adds some methods (such as a request for an index of
subfolders, formatted as HTML, for instance).

>> > DTML is horrible.
>> Ah, so you found out, huh? :) DTML is horrible compared to Python.
>> There are some guidelines to keep it simple. And move to Python
>> as soon as you feel your DTML becomes too horrible.

> There's not much info on interfacing with Python. And then the interface is
> DTML-ish?!

Simple interfacing to Python isn't that hard. You can write an external

def foo(self, arg):
    return "the arg is: " + arg

and call it like this:

<dtml-var "foo('hey!')">

Which'll get you this on your page:

the arg is: hey!

You can also return lists, such as here:

def get_a_list(self):
    return [1, 2, 3, 4]

And you can use this with dtml-in, for instance:

<dtml-in "get_a_list()">
  <li><dtml-var sequence-item></li>

Through the 'self' parameter you can access methods (possibly acquired)
of the object in which context you're calling the external methods. Such as:

def get_first_sub_element(self):
    return self.objectValues[0]

>> > How does persistence work for Python objects?
>> Basically, automatically (if you inherit from the right base classes in
>> Zope), as long as you treat all members of your objects as immutable.
>> That means that if you have an object a with a list l as an attribute:

> Which class?!

Oh, any class, basically. To make an class persistent in Zope, do this:

from Globals import Persistent

class MyClass(Persistent):

This is in the intro document on the ZODB, by the way. :)

> Bit messy, but I see the point. How do you flag it, out of interest?

That's in the intro to the ZODB too, so I'll look it up for you:

self._p_changed = 1

And the link again:


History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?

More information about the Python-list mailing list