[ZODB-Dev] Re: false write conflicts
Marius Gedminas
mgedmin at b4net.lt
Wed Mar 3 09:31:08 EST 2004
On Wed, Mar 03, 2004 at 10:04:15AM +0000, Chris Withers wrote:
> Marius Gedminas wrote:
>
> >I've seen a recommendation somewhere that it is better to write
> >
> > self.attr[x] = y
> > self.attr = self.attr # notify Persistence that something changed
> >
> >than
> >
> > self.attr[x] = y
> > self._p_changed = True # notify Persistence that something changed
>
> Why is that?
I don't remember. ;)
<googles>
It seems that I misremembered the suggestion -- it is better to use
_p_changed rather than attribute assignment:
http://mail.zope.org/pipermail/zope3-dev/2002-September/002771.html
And I made another mistake as well: the persistence should be triggered
*before* modifying self.attr, not after (cf. the same thread).
Nevertheless there exists code somewhere in the wild that uses the first
idiom to trigger persistence. Accidentally mixing this code with a
__setattr__ wrapper could introduce bugs. It is probably very unlikely
in practice, but I like to point out such possibilities.
Marius Gedminas
--
Any sufficiently advanced technology is indistinguishable from a rigged demo.
- Andy Finkel, computer guy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040303/e4b9fa6f/attachment.bin
More information about the ZODB-Dev
mailing list