Randomness (RE: [Zope-dev] CoreSessionTracking 0.8)
Bjorn Stabell
bjorn@exoweb.net
Sat, 26 May 2001 01:44:06 +0800
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?
Bye,
--=20
Bjorn
-----Original Message-----
From: Matt Hamilton [mailto:matth@netsight.co.uk]
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 =3D context.session_mgr.getSessionData()
>=20
> cart =3D session.get('shopping_cart', {})
>=20
> sku =3D int(sku)
>=20
> if not cart.has_key(sku):
> cart[sku] =3D 0
>=20
> if int(qty)>0:=20
> cart[sku] =3D 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 =3D 1 to the code after
modifying cart{}.
-Matt
--=20
Matt Hamilton matth@netsight.co.
uk
Netsight Internet Solutions, Ltd. Business Vision on the
Internet
http://www.netsight.co.uk +44 (0)117
9090901
Web Hosting | Web Design | Domain Names | Co-location | DB
Integration
_______________________________________________
Zope-Dev maillist - Zope-Dev@zope.org
http://lists.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -=20
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope )