Ross,

Please see the bit about "inheritedAttribute" in the document inside
Zope's source tree named
lib/Components/ExtensionClass/doc/ExtensionClass.html.

HTH,

- C

----- Original Message -----
From: "Ross Boylan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Ross Boylan" <[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 3:30 AM
Subject: [Zope-dev] Extension class and __init__


> I had the bright idea of defining a mixin class whose methods I
> thought I could use in my regular Zope product classes:
>
> class AMixin:
>   def __init__(self):
>      blah, blah blah
>
> class B(AMixin, Persistent, Folder, ....):
>   def __init__(self):
>     # do some of my own stuff
>     AMixin.__init__(self)
>
> This fails with the warning (as I recall) that the unbound method
> AMixin.__init__ needs to be called with an instance as its first
> argument.  (I've stripped the example down to give what I think are
> the essentials).
>
> self in the context of B is an Extension class, and I'm guessing
this
> is making AMixin unhappy because it's not.  I assume I'll have the
> same problem with other methods that I attempt to access using
> AMixin.foo(self).
>
> Can anyone confirm this diagnosis?  And what's the best solution?
>
> I have redefined things
> class AMixin:
>   def _mixin_init(self):
>     #stuff
>
> class B(AMixin, .....):
>    def __init__(self):
>     #my own stuff
>     self._mixin_init(self)
>
> and this seems to work, but I wonder if there's a way to get the
> classes to play together better (maybe "class
AMixin(ExtensionClass):"?
> though since ExtensionClass is a type I guess that's not exactly
it).
>
> This was after already discovering that isinstance doesn't work with
> ExtensionClass (which I see confirmed on the list, along with the
fact
> that ExtensionClass generally has a lot of rough spots and may be on
> the way out).  This is with Zope 2.5.1.
>
>
> _______________________________________________
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>



_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to