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. Greetings Florian -- ----------------------------------------------------------------------- | Florian Reiser PGP-Key:0x5368CF3F | | PGP-Fingerprint: 84C7 24BC F3A4 487F CBC7 692C 05DB 6E11 5368 CF3F | -----------------------------------------------------------------------
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
florian_reiser@gmx.de writes:
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. When forming the cookie value, convert the dict into a string (with the "repr" function) and then encode it (either URL-quote or Base 64), to avoid characters not allowed in cookie values.
To transform the cookie value into a dictionary again, decode the value and then eval it. You will need an External Method for the "eval" part, as "eval" is not exposed to DTML. Be carefull! "eval" on untrusted strings is a severe security risk. Use "eval(str,{'__builtins__':None})". This will disable all Python builtins for evaluation, among them the dangerous ones, such as "open", "__import__", ... Dieter
participants (3)
-
Dieter Maurer -
florian_reiser@gmx.de -
Steve Alexander