Nope, couldn't have been, because: I couldn't set _p_changed from Python
Script, but I changed the last line setting the shopping_cart object in
the session to:

        session.set('shopping_cart', cart.copy())

This should create a fresh copy of the dict, which should be sufficent
notice for the persistence machinery (or isn't a shallow copy enough?
cart is a dict of integers).  I also removed the call to
cart_recalculate, just to make sure there were no spooky thing going on
there.  I'm still seeing the bug.

Just a quick question.  In:

        session.set('shopping_cart', cart)

is cart call-by-reference or call by value (cart is a dict).  I guess it
depends if 'set' makes a copy of the dict or not before assignment?

Also, do I really have to make a copy, or is there a way from Python
Script to notify the persistence machinery about a change in a complex
object, e.g., dict?


-----Original Message-----
From: Matt Hamilton [mailto:[EMAIL PROTECTED]]
Posted At: Saturday, May 26, 2001 00:37
Posted To: Zope Developer
Conversation: Randomness (RE: [Zope-dev] CoreSessionTracking 0.8)
Subject: RE: Randomness (RE: [Zope-dev] CoreSessionTracking 0.8)

On Fri, 25 May 2001, Bjorn Stabell wrote:

> session = context.session_mgr.getSessionData()
> cart = session.get('shopping_cart', {})
> sku = int(sku)
> if not cart.has_key(sku):
>   cart[sku] = 0
> if int(qty)>0: 
>    cart[sku] = cart[sku] + int(qty)

Could this be the same problem that I was experiencing, in that
dicts/btrees do not in themselves notify the persitence machinery that
they have changed? try adding cart._p_changed = 1 to the code after
modifying cart{}.


Matt Hamilton                                         [EMAIL PROTECTED]
Netsight Internet Solutions, Ltd.          Business Vision on the
Internet                               +44 (0)117
Web Hosting | Web Design  | Domain Names  |  Co-location  | DB

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to