Can you store a dictionary in a cookie? I've been trying and it keeps barfing on me. If I set the dictionary in the REQUEST, it works just fine, but if I set it as a cookie, and then try to reference it with <dtml-var "cookie['key']"> if bombs with "sequence index must be an integer". Dost it think it's a list? TIA Rick
On Fri, 14 Mar 2003 11:21:26 -0800 GMT (..20:21 where i live(GMT+1) ) D. Rick Anderson asked the Zope mailinglist about the following: DRA> Can you store a dictionary in a cookie? I've been trying and it keeps DRA> barfing on me. If I set the dictionary in the REQUEST, it works just DRA> fine, but if I set it as a cookie, and then try to reference it with DRA> <dtml-var "cookie['key']"> if bombs with "sequence index must be an DRA> integer". Dost it think it's a list? it is a string when you get it back.. cookies are always strings -- Geir Bækholt
Thanks for the reply! ok ... then I guess I need to know how to convert it from a string to a dictionary. Is that possible? Is there something like _.dict(cookie) that will work? Thanks again, Rick Geir Bækholt wrote:
On Fri, 14 Mar 2003 11:21:26 -0800 GMT (..20:21 where i live(GMT+1) ) D. Rick Anderson asked the Zope mailinglist about the following:
DRA> Can you store a dictionary in a cookie? I've been trying and it keeps DRA> barfing on me. If I set the dictionary in the REQUEST, it works just DRA> fine, but if I set it as a cookie, and then try to reference it with DRA> <dtml-var "cookie['key']"> if bombs with "sequence index must be an DRA> integer". Dost it think it's a list?
it is a string when you get it back.. cookies are always strings
-- Geir Bækholt
On Fri, 14 Mar 2003 11:30:35 -0800 GMT (..20:30 where i live(GMT+1) ) D. Rick Anderson asked the Zope mailinglist about the following: DRA> Thanks for the reply! DRA> ok ... then I guess I need to know how to convert it from a string to a DRA> dictionary. Is that possible? Is there something like _.dict(cookie) DRA> that will work? not sure. i would guess you would have to make your own format/parser according to your needs. Tough if you are to handle all cases on a general basis, simple if you know what the dicts will be like. :) - also : there is a limit (255 ?? ) to how long cookie strings can be , so cookies are really not a very good tool for complex data storage You could prehaps get around the problem by using sessions instead ? -- Geir Bækholt
I've never used Sessions before. Is there a good howto? Thanks, Rick On Fri, 2003-03-14 at 12:05, Geir Bækholt wrote:
On Fri, 14 Mar 2003 11:30:35 -0800 GMT (..20:30 where i live(GMT+1) ) D. Rick Anderson asked the Zope mailinglist about the following:
DRA> Thanks for the reply!
DRA> ok ... then I guess I need to know how to convert it from a string to a DRA> dictionary. Is that possible? Is there something like _.dict(cookie) DRA> that will work?
not sure. i would guess you would have to make your own format/parser according to your needs. Tough if you are to handle all cases on a general basis, simple if you know what the dicts will be like. :)
- also : there is a limit (255 ?? ) to how long cookie strings can be , so cookies are really not a very good tool for complex data storage
You could prehaps get around the problem by using sessions instead ?
-- Geir Bækholt
On 14 Mar 2003 12:22:47 -0800 GMT (..21:22 where i live(GMT+1) ) D. Rick Anderson asked the Zope mailinglist about the following: DRA> I've never used Sessions before. Is there a good howto? the Zope book (2.6 ed.) is your friend :) http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/Sessions.stx -- Geir Bækholt
On Friday, March 14, 2003, at 02:30 PM, D. Rick Anderson wrote:
ok ... then I guess I need to know how to convert it from a string to a dictionary. Is that possible? Is there something like _.dict(cookie) that will work?
I just use the pickle module. You'll have to implement it as an External Method, but it works fine for me. ___/ / __/ / ____/ Ed Leafe http://leafe.com/ http://opentech.leafe.com
participants (3)
-
D. Rick Anderson -
Ed Leafe -
Geir Bækholt