[Zope] cookie problem

Hung Jung Lu hungjunglu@hotmail.com
Mon, 31 Jan 2000 10:49:08 PST


"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

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com