[Zope] RE: CST and disappearing variables (still)
Chris McDonough
chrism@zope.com, chrism@zope.com
Mon, 01 Oct 2001 22:42:27 -0400
>
> Is there anything special I need to be concerned about regarding
persistence
> when using CST?
Just what's in the documentation.. which by the rest of your message it
appears you've already read (or you intuited the right way of doing things).
> For example, in a Python Script, I do the following:
>
> item = {}
> ... populate item with some stuff ...
>
> cart = session.get('cart', [])
> cart.append(item)
> session.set('cart', cart)
>
> Is this something that CST should be able to handle properly?
Yes... the last session.set is necessary due to the mutability of
"cart", but you knew that.
> The only other thing I do that might be strange is getting the
session data
> more than once in a transaction as follows:
>
> When the final Python Script 'sendOrder' is called from the Web, it goes
> something like this:
>
> session = context.SDM.getSessionData()
> message = container.message(container, custinfo=session['custinfo'])
> ... send message ...
>
> The DTML Method 'message' called above has this:
>
> <dtml-with custinfo mapping>
> ... name, address, etc. variables from 'custinfo' ...
> </dtml-with>
>
> <dtml-var textview>
>
> The DTML Method 'textview' inserted at the end of the 'message' has this:
>
> <dtml-let items="Items()">
> <dtml-unless items>
> Your cart is empty.
> </dtml-unless>
> <dtml-if items>
> <dtml-in items mapping>
> ... display items ...
> </dtml-in>
> </dtml-if>
>
> The Python Script 'Items' is as follows:
>
> session = context.SDM.getSessionData()
> return session.get('cart', [])
>
> So, 'textview' calls the Python Script 'Items' which gets the session
data
> again. Is there anything wrong with doing this, or can you see anything
> dangerous in my logic? It seems so clear and simple to me, but I'm
> questioning pretty much everything now.
No, it seems normal. :-( Darn.
You're not working with multiple frames or windows, are you?
--
Chris McDonough Zope Corporation
http://www.zope.org http://www.zope.com
"Killing hundreds of birds with thousands of stones"