[Zope] cookie problem
Terry Kerr
terry@adroitnet.com.au
Tue, 01 Feb 2000 10:00:12 +1100
Hung Jung Lu wrote:
> "stuart 'zen' bishop" <ze-@cs.rmit.edu.au> wrote:
> >On Mon, 31 Jan 2000, Terry Kerr wrote:
> > > I am having problems trying to set a cookie when the cookie is a pickled
> > > object. It appears to be a problem when the string representation of
> > > the pickled object containes carrage returns. ...setCookie seems to barf
> > > in this situation. Anyone else had problems with this and/or found work
> > > arounds?
> >from base64 import decodestring, encodestring
> >cookie = encodestring(pickledstuff)
> >And to reverse
> >pickledstuff = decodestring(cookie)
>
> Hmm... are you sure base64 is good enough? I was using
> base64's encoding, but then I was still running into
> problems. I don't remember the exact situation,
> but base64 was not good enough.
>
> At the end, I had to switch to urllib, by using
> urllib.quote_plus() and urllib.unquote_plus().
> The resulting string was bulkier, I didn't like it
> too much... but at least it did not fail like
> base64.
>
> Hung Jung
>
Umm...Yes, base64 didn't work for me, but neither did urllib.quote_plus() !!
My pickled cookies have carrage returns in them, and unquoting the cookie just
returns an error. The only method I have found so far is to string.replace all
'\012' with "\\012".
terry
--
Terry Kerr (terry@adroitnet.com.au)
Adroit Internet Solutions PTY LTD (www.adroitnet.com.au)
(03) 9888 8522
0414 938 124