[Zope] store dict in session

Dieter Maurer dieter at handshake.de
Thu Jan 11 16:29:44 EST 2007


Peter Bengtsson wrote at 2007-1-10 20:23 +0000:
>Quite possible that you have a form with something like this:
>
><input name="user.age:record" value="50" />
><input name="user.name:record" value="Dee" />
>
>In python, if you do this::
>
>def saveUser(self, user, REQUEST):
>     print user # will print {'age':'50', 'name':'Dee'}
>     REQUEST.SESSION.set('user_data', user) # will fail!
>
>So you have to do this::
>
>def saveUser(self, user, REQUEST):
>     user = dict(user)
>     print user # will print {'age':'50', 'name':'Dee'}
>     REQUEST.SESSION.set('user_data', user) # will work!

"ZPublisher.HTTPRequest.record" instances (they are used
for ":record" form variable) are picklable.
Thus, there should be no difference
when you store a "record" "r" or "dict(r)" in the session.



-- 
Dieter


More information about the Zope mailing list