[Zope] Bound methods, acquisition, __init__, Unpickleable object
Bo Granlund
granbo@uiah.fi
Mon, 9 Jul 2001 15:25:12 +0300
Hello zope users,
I have this little problem with bound methods and __init__. I have
written something like:
class Root(Acquisition.Implicit, Persistent):
def __init__(self):
self.container = []
def register_func(self, func):
self.container.append(func)
class Spam(Acquisition.Implicit, Persistent):
def foo(self): pass
def __init__(self):
# This fails at Root.register_func, in self.container.append
self.register_func(self.foo)
def add_bound_method(self):
# Works like charm, when called explicitly
self.register_func(self.foo)
This results in UnpickleableError, 'Cannot pickle objects' when
adding the product. Now if I call register_func from somewhere
else than __init__ or manage_afterAdd, there is no problem, and
everything works as I expect it to work. This is propably
explained somewhere in deep detail, and I have managed to miss
that documentation. Any pointers to documentation or ideas on
how to set bound methods to other objects would be appreciated.
Best regards,
Bo Granlund