[Zope] Re: losing random session data

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Mon Mar 19 15:41:36 EDT 2007


> This does the trick:
> 
>     order = []
>     new_order={}
>     prev_order=req.SESSION.get('order')
> 
>     if prev_order != None:
>      for orders in prev_order:
>        for item in orders.keys():
>         new_order[item]=orders[item]
>        order.append(new_order)
>        new_order ={}
This seems to be hardcore ;) I mean that it should not
be necessary to do such rewrite of all keys and values
for dictionaries or lists taken from session.
I never had to do something like that...

Isn't it working without these assignments? Just:

order=req.SESSION.get('order', []) # if there is no 'order' in session
                                   # you'll simply get empty list here
new_order = {}
for val in req.form.keys():
    new_order[val]=req.form[val]
order.append(new_order)
req.SESSION['order'] = order


BTW. req.SESSION.set(..., ...) method is also persistence aware
(according to zope book)

-- 
Maciej Wisniowski


More information about the Zope mailing list