[Zope] Cookies and dictionaries

Kashif Jabbar kjabbar at ssidecisions.com
Fri Feb 6 15:01:01 EST 2004


Hello,

I am trying to store a dictionary in a cookie which I would like to 
retrieve later and use. A test python script is as follows:

##########
request = container.REQUEST
response =  request.RESPONSE

dic = {'filter':'yes'}
response.setCookie('myCookie', dic)
if request.has_key('myCookie'):
    mydic = request.myCookie
    print mydic['filter']

return printed
###########

When the script is run I get an error:

> *Error Type: TypeError*
> *Error Value: sequence index must be integer*

It seems that the dictionary is returned as a string. How can I cast 
this string to a dictionary type?

Thanks.
Kashif






More information about the Zope mailing list