[Zope-dev] Cookie with dictionary as content
Steve Alexander
steve@cat-box.net
Sat, 09 Jun 2001 19:08:26 +0100
florian_reiser@gmx.de wrote:
> Hi guys,
>
> I'm developing the ZPivotTable product. For implementing the drilldown
> mechanism, I need to store the information about which columns and rows
> are open in a cookie. I thougt of storing this information in form of
> a dictionary, which would be stored in a cookie.
>
> The dictionary consists of several lists, containing the open columns
> or rows.
>
> Could you give me a tip how i can store the dictionary in the cookie.
> I've already tried to converting it to a string and converting the string
> back, when needed.
You could consider using a session manager, and only store an id in the
cookie.
Otherwise, look at how the dtml tree tag achieves what you describe. You
have to be a bit careful that you only serialize pure data and not
pickled objects into your cookie, otherwise you're opening up a huge
security hole.
Look at the source in lib/python/TreeDisplay/TreeTag.py, around line
578, in the methods encode_seq and decode_seq.
--
Steve Alexander
Software Engineer
Cat-Box limited