[Zope] Using Zclasses

Alexander Staubo alex@mop.no
Tue, 6 Jul 1999 02:49:00 +0200


To answer your first question, let your "parent" ZClass be a descendant
of Object Manager; then define your "child" ZClass _within_ the parent
ZClass definition; that is, add the child ZClass as a subobject of the
parent.

Your second question is trickier, because Zope does not, afaik, support
properties that are objects. It's possible, but I believe you can't edit
these properties through the standard management interfaces. Instead,
you must built your own, and you might have to use Python to store these
properties. You might want to look at the implementation of Confera and
study the code for its mail host property: I don't know if this is
implemented by referring to the mail host objects' _name_ or the
instance itself though.

The alternative, of course, is to use a string property and refer to the
object's ID. Acquisition will permit you to access any object in the
hierarchy above the object in question.

--
Alexander Staubo             http://www.mop.no/~alex/
"What the hell, he thought, you're only young once, and threw
himself out of the window. That would at least keep the element of
surprise on his side."
--Douglas Adams, _The Hitchhiker's Guide to the Galaxy_

>-----Original Message-----
>From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
>Michael Bernstein
>Sent: 6. juli 1999 02:07
>To: zope@zope.org
>Subject: [Zope] Using Zclasses
>
>
>I've been playing around with Zclasses for awhile, but have reached a
>bit of a stumbling block.
>
>I want to create a set of Zclasses that can only be contained within
>certain other Zclasses. An arbitrary example would be a 'book' object
>that can only be created inside a 'shelf' object.
>
>I also would like to add a property to a ZClass that is a pointer to an
>instance of another ZClass of a certain type. An arbitrary
>example would
>be a 'Book' ZClass that has an 'Author' property that points to an
>instance of an 'Author' ZClass.
>
>Does anyone have any hints as to how to accomplish this sort of thing?
>Feel free to recast the problem in terms of the ZClasses tutorial 'CD'
>examples.
>
>Michael Bernstein.
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://www.zope.org/mailman/listinfo/zope
>
>(For developer-specific issues, use the companion list,
>zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>