[Zope] Using "Class-Hierarchies" in Zope
Dieter Maurer
dieter@handshake.de
Thu, 5 Jun 2003 22:34:26 +0200
Andreas Pakulat wrote at 2003-6-5 15:28 +0200:
> I've got a question regarding ZClasses and the building of
> Hierarchies using them.
>
> For example I have ZClass A and the ZClasses B and C "derived" from A
>
> What does Zope do if I create a new Instance of B using
> manage_addProduct['myproduct'].B_add(myparam). I know that the B_add
> Script I created is called, but is also the A_add Script called,
No, it is not called.
> or can
> I call it in the B_add script,
You can, but almost surely it will not do what you expect
(it probably will create a *new* "A" instance, independent from
your "B" instance).
, or do I have to reimplement all necessary
> things from A_add in B_add?
You "A_add" probably contains 2 parts:
1. create a new "A" instance
2. initialize the new instance
Factor out part 2 (in a separate script inside your product).
Call it in both "A_add" and "B_add".
Note that when a ZClass "B" derives from a ZClass "A",
then both should be in the same product.
Otherwise, the relation between the two classes is lost
during export or distribution.
Dieter