[Zope] Re: FSSession newbie problem

Pavlos Christoforou pavlos@gaaros.com
Fri, 9 Jun 2000 10:37:52 -0400 (EDT)


On Fri, 9 Jun 2000, Marcello Lupo wrote:


> 
> 1) Is necessary to call FSSession in every document of the site or is
> sufficient on the first page (home page of the e-com for example)?
>  Becouse i noticed (obviously) that every time it open a file the HD.
> And i think this is a problem because every time it initialize a new
> session passing the new cookie to the Browser (i think).

Yes it is neccessary beacuse HTTP is stateless. It will only start a new
session if FSSession cannot find a valid UID either through a cookie or a
FORM or as part of te URL

> 
> 2) How may i change the value of an element in a dictionary contained in
> FSSession?
> 
>   Example: I have the object 'carrello' as in the examples before that
> contain a dictionary passed to it from the form.
>   I store the quantity of the item ordered in the value
> 'quantita_prodotto' in the object 'carrello'.
>   If a user add another piece of that item i need to update the
> 'quantita_prodotto' summing to it the new item.
>   I think this is possible but i ignore the syntax to do this.
> 

As you descripe in your example carrello is a dictinory. So one way is to
make quantitita_prodotto a list and append to it. Something like
<untested>

<dtml-if "FSSession['carrillo'].has_key('quantita_prodotto')">
<dtml-call 
"FSSession['carrillo']['quatita_prodotto'].append(REQUEST.form['quatita_prodotto'])">
<dtml-else>
<!-- need to fake the = sign which cannot be used in DTML expr-->
<dtml-call "FSSession['carrillo'].update({'quatita_prodotto':[]})">

</dtml-if>

plus some more logic to check if the variables are empty/correct etc ..

Pavlos