[Zope-dev] Acquisition and Threads
Chris McDonough
chrism@zope.com
Fri, 07 Dec 2001 09:06:55 -0500
When you inherit from Acquisition.Implicit, your class becomes an
extension class. The idiom that the Thread mixin uses is that you
always need to call its init, and it expects self to be an instance of
the "Thread" Python class in some way. It is instead an extension class.
One way to solve it is to work around the problem by not inheriting from
both Implcit and Thread in the same class. Another way is to override
__init__ and use the "inheritedAttribute" idiom to call the superclass'
__init__ with something it can deal with. Search the maillist for more
info.
Magnus Heino wrote:
> Can someone please tell me what is going on here?
>
>
>
>
> [magnus@bombardier magnus]$ cat aq.py
>
> from Acquisition import Implicit
> from threading import Thread
> import time
>
> class A(Implicit, Thread):
>
> def run(self):
> print context.aq_self
>
>
> class B(Implicit):
> pass
>
> b = B()
> b.a = A()
> b.a.start()
> time.sleep(2)
>
> [magnus@bombardier magnus]$ python2 aq.py
> Traceback (most recent call last):
> File "aq.py", line 16, in ?
> b.a = A()
> File "/usr/lib/python2.1/threading.py", line 326, in __init__
> _Verbose.__init__(self, verbose)
> TypeError: unbound method __init__() must be called with instance as first
> argument
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> 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 )
>
--
Chris McDonough Zope Corporation
http://www.zope.org http://www.zope.com
"Killing hundreds of birds with thousands of stones"