On Dec 1, 2007 10:49 AM, Paul Winkler <[EMAIL PROTECTED]> wrote:
> On Sat, Dec 01, 2007 at 02:34:49AM +0800, Yuan HOng wrote:
> > Hi,
> >
> > It seems that I can not get list attribute of an persistent object
> > changed. I have the following class, which has a list as one of its
> > attributes:
> >
> > class Cart(Persistent):
> >     items = []
> >     amount = 0
>
> I hope that's not your actual code. Note here that items is a mutable
> class attribute, so if you do this:
>
> cart = Cart()
> cart.items.append('foo')
>
> ... you've just mutated the default list for all instances.  Is that
> really what you want?  ZODB persistence can only store instance
> attributes, not class attributes.
>
> But that's irrelevant to the rest of your examples, because you
> re-assigned cart.items, which should work. I don't know what's wrong
> there.
>

I found out now that using PersistentList does solve the problem. I my
previous try I overwrote the empty persistent list with a normal list,
so the test failed.

But using _p_changed on a normal list seems to no longer be useful.

-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to