[mod_python] newbie cookie confusion

Sells, Fred fred at adventistcare.org
Mon Oct 9 16:32:23 EDT 2006

I am using the mod_python.publisher; could that mess me up with cookies
I'm just trying to get the basic demo from the manual to work.

I notice the manual writes a plain cookie but reads a marshall cookie.  Am I
correct in assuming these are not compatible cookies, and you had better
read the type you wrote?

Sells, Fred wrote:
> I've googled but not found this, trying to do cookie example from docs.
> output is always of type <type 'str'> and is the cookie name.  How do I
> value?
> def makecookie(req):
>     c = Cookie.MarshalCookie('spam', 'eggs', 'secret007')
>     d = Cookie.MarshalCookie('xxxx', 'yyy', 'secret007')
>     Cookie.add_cookie(req, c)
>     Cookie.add_cookie(req, d)
>     return 'cookie made'
> def showcookies(req):
>     cookies = Cookie.get_cookies(req, Cookie.MarshalCookie,
> secret='secret007')
>     s = 'There are %s cookies'% len(cookies)
>     for c in cookies:
>         s += '\n%s %s' % (str(c), type(c))
>     return s

I haven't been through the docs but I'd suggest that you have a look at 
cookies[c] in case cookies is a dictionary.


More information about the Mod_python mailing list