[Zope] __setstate__ and acquistion
Terry Hancock
hancock at anansispaceworks.com
Thu Nov 27 22:17:01 EST 2003
On Thursday 27 November 2003 12:42 pm, Terry Hancock wrote:
> Okay, I was trying to use acquisition from within a
> __setstate__ method. Doing a little searching I was
> able to find a message from the Zope list (circa 2001)
> saying that you can't do it, because the self that
> __setstate__ acts on isn't acquisiton wrapped.
Actually, I did figure out a work-around that fits my
problem:
I added a step in my manage_addTopic() script like
this to make a local reference to the "View" attrib I'm
trying to acquire:
ob = Topic(...)
ob.ViewAlias = self.View
self._setObject(id, ob)
ob = self._getOb(id)
View is a PersistentMapping, so I presume it will act like
a normal mutable Python object (so when I make changes
to its contents, they'll show up in the alias). I'll have
to test this, anyway, to make sure, of course.
In the __setstate__ method, Topic computes using the
ViewAlias which is a local attribute:
for view in self.ViewAlias.keys():
#... do some stuff with this view info
pass
That seems to solve the problem.
Thanks for the replies,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Zope
mailing list