[prev in list] [next in list] [prev in thread] [next in thread]
List: zope
Subject: Re: [Zope] Using "Class-Hierarchies" in Zope
From: J Cameron Cooper <jccooper () jcameroncooper ! com>
Date: 2003-06-05 22:28:12
[Download RAW message or body]
>
>
>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::
A.A_add(id, parameters)
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.
--jcc
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic