John J. Lee
jjl at pobox.com
Thu Aug 12 22:12:35 CEST 2004
fuzzyman at gmail.com (Michael Foord) writes:
> Ok, I've got somewhere.
> I'm now using the 0.9 version and I found the debugging section in the
> I'm using the example from the docs - but I'm pickling a list of the
> pickles rather than using the load and save methods (as the docs
> suggest) because I get an NotImplemented error for the save method (so
> what use is the load method ?).
I suppose you're trying to use FileCookieJar. That's an abstract base
class. In other words, you're not supposed to use it directly.
You're supposed to use one of its subclasses, such as LWPCookieJar,
MSIECookieJar or MozillaCookieJar. The standard meaning of
NotImplementedError is not "oops, I haven't got round to that", but
rather "don't do that; use a subclass instead".
MSIECookieJar can't save cookies because the format used by Windows
isn't documented (there is an API function, but I don't use it).
> and I'm now seeing persistent cookies..... hurrah.......
> Can I save each cookie as a line of text ? Would that work with the
> load method ?
Yes. Use LWPCookieJar.
> Anyway - now I need to learn about server side cookies so that I can
> give each user an 'id'
Have a look at some of the Python web frameworks.
> and also write code to clean up unused cookie
- simply always have one file per user, and persist it by whatever
means you like (LWPCookieJar, pickling,
outfile.write('\n'.join([repr(c) for c in cookiejar])),
- write a CookieJar that hides its implementation in terms of
multiple files (and implements .clear_expired_cookies(), etc.).
Probably not a good idea.
More information about the Python-list