[Zope] Using "Class-Hierarchies" in Zope
J Cameron Cooper
Thu, 05 Jun 2003 17:28:12 -0500
>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, or can
>I call it in the B_add script, or do I have to reimplement all necessary
>things from A_add in B_add?
I usually stay well away from ZClasses, but unless they're *really*
strange, it should work like in Python products...
The B_add function is explicitly used (and nothing else.) In that
function you may call an appropriate function from a superclass like::
but be careful, because product add scripts like to create objects
rather than initialize. You'll want to call an initialization method
instead (like you should be using in A_add)::
def B_add(self, id, parameters):
obj = B(id, parameters)
A.__init__(obj, id, parameters)
# everything else, then add to 'obj' to 'self'
In newer Python, you can use the super() call.