[ZODB-Dev] Re: How to avoid shooting oneself in the foot

Jeff Sasmor jsasmor@gte.net
Mon, 7 Oct 2002 10:46:42 -0400


Jeff Bauer writes:

>In ZODB it is necessary to manually mark modified 
>objects when objects attributes are modfied in place 
>(e.g. lists and dicts).

>Q1: Is this a "real world" problem that bites people
>in the buttocks?

Yes, but if you use PersistentList and PersistentMapping 
that's not an issue.  The _p_changed stuff is never needed.

There are some places in my code where I don't use these
classes, and there I am careful to use _p_changed
when a list or dict is altered. Small price to pay for the
wonderfulness of 'almost' transparent persistence. 

>Q2: Is it usually easy to figure out when it happens,
>or is the problem difficult to track?  (If the latter,
>any war stories would be appreciated.)

I guess it depends on the application - if some attr whose 
value should have changed from one run of the program
to another has not changed, well then it's really obvious.
It may be easier to see on platform apps than on web apps.
A debugger is nice to trace thru your code and ensure that
things are as you expect them to be. There are some
good tools around these days.

>Q4: (Bonus points)  Does anyone here use the Java-style
>accessor method (or Andrew's PersistentList class) for
>their ZODB applications?

I use PersistentList and PersistentMapping and have
had no probs.

HTH,
_____________________________________
Jeff Sasmor
jeff@sasmor.com