ANN: ClientCookie 0.4.1a released

John J. Lee jjl@pobox.com
09 Jun 2003 20:59:17 +0100


http://wwwsearch.sourceforge.net/ClientCookie/

A new development release.

I'm not going to maintain 0.3.x now other than for easy fixes.  0.4.x
includes interface changes, but it isn't hard to switch, as long as you
read the list below.  If your code doesn't pass arguments to the Cookies
constructor, you probably won't have to change anything at all.

This is an alpha release: interfaces may change (probably not, though).
0.4.1a may or may not be more broken than 0.3.5b: lots of bugs have been
fixed, but quite a bit has changed, too.

Interface changes since 0.3.5b:

 * The Cookies class now decides whether to accept or reject cookies
   using a CookiePolicy object.  This simplifies Cookies, and together
   with the switch to using Cookie objects rather than tuples, makes it
   easier to customise the module's behaviour.  Many arguments from the
   Cookies constructor were moved to CookiePolicy, and it's default
   implementation, DefaultCookiePolicy.

 * Removed autosave feature.

 * Constructors of Cookies objects no longer try to load from the
   filename filename passed to the constructor -- you have to explicitly
   call the load method.  Also, ignore_discard is now an argument of the
   load, save and revert methods (together with the new ignore_expires
   argument), rather than an attribute as it used to be.

 * MSIECookies constructor no longer tries to load from the file given
   in the registry.  You have to call the load_from_registry method
   explicitly.  Also, fixed a bug which broke the whole thing.

 * Several methods and arguments have been renamed:

   Methods:
    clear_temporary_cookies --> clear_session_cookies

   Arguments:
    redirect --> unverifiable (everywhere that argument occurred)
    in Cookies.clear method: key --> name

 * scan method is gone, in favour of iterator (1.5.2-compatible, via the
   __getitem__ hack).

 * Cookies are now represented by Cookie objects (more of a struct than
   an object, really).  As a result, the set_cookie method now takes a
   Cookie object, not a tuple, and there is a new set_cookie_if_ok
   method that will set a Cookie 'manually', but only if it passes the
   usual tests against the Request.  Cookies.cookies dictionary now
   contains Cookie objects.

 * delayload is now a public attribute.

 * str2time supports fewer formats (which I always warned about).

 * NetscapeCookies is renamed MozillaCookies to make it clear the name
   refers to the browser, not the protocol.  Several bugs have been
   fixed here, too.

 * Modified domain blacklist algorithm: .foo.com now blocks
   rhubarb.foo.com and www.rhubarb.foo.com, but foo.com only blocks
   foo.com.


Other changes:

 * Added domain whitelist.  Blacklist is checked first, then the
   whitelist, if one is set.

 * Added clear_expired_cookies method.

 * Fixed lots of bugs.

 * Added some new bugs, no doubt.

 * Added some strictness switches, to control which cookies are accepted
   and sent back to server.

 * RFC 2965 rules on third party unverifiable transactions are followed,
   finally!  You can also block Netscape cookies using the same rule, if
   you like, using one of the strictness switches.  This is like some
   browsers' "Enable cookies for the originating web site only" feature.

 * Date handling code is now simpler -- many formats have been removed.

 * Clean-up of code and docs.

 * I've put up an example script that makes use of ClientCookie and
   ClientForm (and ClientTable if you have it -- which you won't,
   because I haven't released the required version yet :-).  It involves
   redirects, cookies, HTTPS (if your Python has HTTPS support), forms
   and tables.

  http://wwwsearch.sourceforge.net/bits/fastmail.py


Requires Python >= 1.5.2.

ClientCookie is a Python module for handling HTTP cookies on the client
side, useful for accessing web sites that require cookies to be set and
then returned later.  It also provides some other (optional) useful stuff:
HTTP-EQUIV handling, zero-time Refresh handling, and lazily-seekable
responses.  It has developed from a port of Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Simple usage:

 import ClientCookie
 response = ClientCookie.urlopen("http://foo.bar.com/")

This function behaves identically to urllib2.urlopen, except that it deals
with cookies automatically.  That's probably all you need to know.



John