cookie

Ajay abra9823 at mail.usyd.edu.au
Sat Aug 28 00:38:14 EDT 2004


Quoting "John J. Lee" <jjl at pobox.com>:

> Ajay <abra9823 at mail.usyd.edu.au> writes:
> > Quoting "John J. Lee" <jjl at pobox.com>:
> > > Ajay <abra9823 at mail.usyd.edu.au> writes:
> [...]
> > > > i am printing a simple cookie, but instead of printing
> > > > um=name:blah&access:admin&exp:2312390.909
> > > >
> > > > its printing
> > > > um="name:blah&access:admin&exp:2312390.909"
> > > >
> > > > why the quotes?
> > >
> > > Why not?
> > >
> > > I don't see how they'd cause any harm.
> > >
> > they dont cause any harm, except for a an extra statement removing
> those
> > quotes when i read the cookie, parse it and authenticate the session.
> > the question is - is that normal cookie behaviour?
> > cookie["test"]="blah"
> > print cookie
> >
> > prints test=blah and not test="blah"
> > so why the quotes when i do the same thing, but use a variable instead
> of a
> > string literal?
>
> You've lost me, but on the basis of a very quick test, the Cookie
> module preserves quotes across the parse->output cycle:
>
> >>> import Cookie
> >>> c = Cookie.SimpleCookie()
> >>> c.load('foo=bar')
> >>> print c
> Set-Cookie: foo=bar;
> >>> c.load('foo="bar"')
> >>> print c
> Set-Cookie: foo="bar";
> >>>
>
> That seems sensible behaviour to me, since quotes around cookie values
> are significant for Netscape cookies (ie. regular, vanilla, internet
> cookies).
>
> I can categorically state that using a variable name instead of a
> string literal will make no difference whatsoever.

i believe you. i didn't think it would make a difference. and i agree that
the Cookie module preserves quotes across the parse->output cycle
my question is
>>> import Cookie
>>> c = Cookie.SimpleCookie()
>>> c["test"]= "blah"
>>> print c
Set-Cookie: test=blah;
>>> c["test"] = "blah" + "testing"
>>> print c
Set-Cookie: test=blahtesting;
>>> str = "testing blah"
>>> c["test"] = str
>>> print c
Set-Cookie: test="testing blah";

why does the final print statement have the quotes. Note i haven't put
str='"testing blah"'. if i had done that i would understand the quotes
there.

>I think you're
> actually confused about Python syntax rather than the workings of the
> Cookie module.  Try reading the Python language tutorial at
> www.python.org.
>
yes i should probably read that :)
it doesn't though mention anything about the above behaviour

cheers

>
> John
> --
> http://mail.python.org/mailman/listinfo/python-list
>


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Python-list mailing list