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

In the debug console, I find that only with direct attribute
assignment can I change the persisted attribute value. If I use
items.append to modify the list, even after I set the _p_changed
attribute of the cart object to True and commit, the persisted version
won't change.

I also tried to use PersistentList as the type of the 'items'
attribute. It doesn't work either with append.

What could be missing? I am using Zope 3.4.

Below is the debug output:


Welcome to the interactive debug prompt.
The 'root' variable contains the ZODB root folder.
The 'app' variable contains the Debugger, 'app.publish(path)'
simulates a request.
>>> from myproject.cart import Cart
>>> cart = Cart()
>>> cart.items=['Item1', 'Item2']
>>> root['mycart']=cart
>>> import transaction
>>> transaction.commit()

After this I break out of the debug session and re-enter it:

Welcome to the interactive debug prompt.
The 'root' variable contains the ZODB root folder.
The 'app' variable contains the Debugger, 'app.publish(path)'
simulates a request.
>>> cart=root['mycart']
>>> cart.items
['Item1', 'Item2']
>>> cart.items.append('Item3')
>>> cart._p_changed = True
>>> import transaction
>>> transaction.commit()

Break again:

Welcome to the interactive debug prompt.
The 'root' variable contains the ZODB root folder.
The 'app' variable contains the Debugger, 'app.publish(path)'
simulates a request.
>>> cart=root['mycart']
>>> cart.items
['Item1', 'Item2']

So the list attribute is NOT changed. Does _p_changed no longer work
with Zope 3.4?

Looking for advices. Thanks.

-- 
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