On Wed, Feb 15, 2006 at 01:21:14PM +0000, Peter Bengtsson wrote:
> I understand the mutation stuff and I always do it like this in zope2
> (I'm a complete beginner in the zope3 world eager to learn):
> def updatesometing(self):
>    #self.numbers['Peter'] = "0779 123 456"
>    numbers = self.numbers
>    numbers['Peter'] = "0779 123 456"
>    self.numbers = numbers
> But in zope2 land, if I derive from Persistent it magically saves ALL
> attributes defined in __init__ assuming that I post-write to them
> correct as shown above.

That hasn't changed in zope 3.  This is just standard ZODB behavior.
setattr will cause a save on commit regardless of the type of
the value.  If you read Jeff's reply again carefully, he said as much.

PersistentList and PersistentDict are not new, either.
They've been used in Zope 2 projects for ages.

There are still exactly three ways to get sub-object mutations to

1) Set the "dirty bit" by hand, e.g.:

     self._p_changed = 1

2) Re-assign the attribute, e.g.:

     alist = self.alist
     self.alist = alist

3) Using a persistent sub-object, e.g. a PersistentList instance:



Paul Winkler
Zope3-users mailing list

Reply via email to