[Zope-dev] ZClasses comments and questions

Martijn Faassen M.Faassen@vet.uu.nl
Tue, 10 Aug 1999 17:06:40 +0200


Hi there,

I'm unclear about some aspects of ZClasses.

Imagine I have a ZClass 'A'. Instances of this ZClass have a 'messages'
tab where various messages this ZClass can emit can be edited. It should
look something like this:
       ________
------|messages|-------

Foobar reached 10 kelvin:
 ---------------------
 | Your Foobar is too|
 | cold, please heat |
 | it!               |
 ---------------------

Hyperdrive coils unwinded
 --------------------
 | Wind up your     |
 | hyperdrive coils!|
 --------------------

Where the boxes are textareas. The person who uses ZClass A can edit the
particular messages that will be emitted for that instance.

Now, I'm thinking about a class hierarchy where there's a ZClass B that
inherits from A. ZClass B has the same messages as A, but may add a few.
The 'messages' tab should automagically adapt to include the new
messages.

I'm having trouble finding the best way to implement this using
ZClasses. One option is to use propertysheets. I may include a
propertysheet 'Messages' in ZClass A. However, there is no easy way to
get to that propertysheet in ZClass B. I may do it programmatically with
DTML (add a property dynamically upon construction of a B instance),
however, but it's far from ideal.

Another problem with propertysheets is that there isn't a way to have
object properties. My messages have already too many attributes, two; a
title and the messsage contents. Properties have only an id and
contents. Imagine I also want to add a 'criticality level' or whatever
to my messages. I run into trouble with properties.

Another idea I had was to make a special ZClass called 'message'. This
message ZClass would have a property sheet with the title of the
message, and the message itself, and criticality level if necessary,
etc. The idea is then to add an instance of such a Message ZClass to my
own ZClasses whenever I needed to add a message. ZClass A would
implement a message tab that would automatically list all Message
objects as textareas for editing (as described before). If ZClass B adds
a Message, that message automatically show up in the tab.

Apart from the fact that with the latest beta I still can't seem to add
ZClass instances to ZClasses (I saw a report in the collector on this
already), I wonder if this will work at all. Would the contained
'message' ZClass's properties be class attributes or instance attributes
of ZClass A? That is, if I changed the 'Foobar too hot' message for one
instance of ZClass A, would it change for all instances? That is not
what I want.

Some Zope Zen is still needed here to grok ZClasses fully. Am I trying
to push them too far? Should I go for Python, and derive my ZClasses
from a Python class? I would lose the easy way to add configurable
messages (and other configurable stuff) to ZClasses that I had in mind,
but in Python this isn't too hard.

Responses to these musings and questions are very welcome.

Regards,

Martijn