[Zope] CST and disappearing variables

Ron Bickers rbickers-dated-1002336032.f3e85c@logicetc.com
Fri, 28 Sep 2001 22:40:31 -0400


I'm running into what appears to be the same problem brought up by others
several months ago regarding "random" disappearing of session variables
under CoreSessionTracking.  After combing through the archives, there didn't
appear to be any definitive answer for the problems.

I *think* my setup is fairly basic, but I can't figure out how to
consistently reproduce the problem.  In fact, *I* haven't been able to make
it happen at all, but every 1-2 out of 10 orders ends up with an empty cart,
and the customer clearly remembers their cart was not empty.

I'm not using ZEO or anything fancy, just the RAM-based storage and cookies.
I have the following setup for adding, updating, and viewing the cart:

Python Script 'add':

'item' is a dictionary that is populated with simple numbers and strings.
'cart' is an array of 'items' and is stored like this:

  session = context.SDM.getSessionData()
  cart = session.get('cart', [])
  cart.append(item)
  session.set('cart', cart)

Python Script 'update':

  A form passes in 'remove' as the cart index of the item to be removed:

  session = context.SDM.getSessionData()
  cart = session.get('cart', [])
  remove = REQUEST.form.get('remove', None)
  if remove is not None:
      del cart[remove]
  session.set('cart', cart)

To place the items in a mail message for sending the order, I use the
following simple Python Script and loop over it with dtml-in:

  session = context.SDM.getSessionData()
  return session.get('cart', [])

This seems so simple, but seemingly randomly the above script returns []
instead of what is in the cart.  There is another session variable (a
dictionary 'custinfo') that is populated towards the end of the user's
ordering process that has so far not been empty on any orders.

I wish I could provide more, but I don't know what else to try.  Maybe
someone can see a flaw in the way I'm storing the cart that might cause CST
to freak...like some persistence triggering problem or something like that.

_______________________

Ron Bickers
Logic Etc, Inc.