urllib2/cookies - surely there's a better way ?

Richard Shea richardshea at fastmail.fm
Sun May 2 05:47:59 EDT 2004


Peter Hansen <peter at engcorp.com> wrote in message news:<84KdnfW3OoNKow_dRVn-vg at powergate.ca>...
> Richard Shea wrote:
> 
> (about urllib2 and cookies)
> 
> Search for "ClientCookie"...

That's great ! I actually laughed when I read the doco - I was only
looking for something to parse cookies with but this does the whole
thing ! I haven't yet used it but I've had a few wriggles getting to
where the 'import ClientCookie' works so I thought I might tell the
newsgroup what I did to make it work (although that might be fairly
obvious to many).

First of all I was installing on a W98 machine. I tried using the
install procedure  "python setup.py build" but I got the message
"error: package directory 'ClientCookie' does not exist". I do have a
slightly weird setup so I wasn't all that surprised.

Anyway I then took the fallback option of copying the 'ClientCookie'
directory from the .ZIP manually. In order to make this work you need
to ensure that sys.path contains a path to ClientCookie before it
finds the standard libraries. I chose to do that by editing the
registry at

HKLM/SOFTWARE/Python/PytonCore/2.3/PytonPath

and adding a new entry there with a value which pointed at the
clientcookie directory (ie C:/a/b/ClientCookie-0.4.18/ClientCookie)
however although I got an extra entry at the 'right' place in sys.path
this didn't allow me to "import ClientCookie" and eventually I
modified the Registry entry to read C:/a/b/ClientCookie-0.4.18 and now
everthing seems to be fine.

This is probably pretty straightforward stuff for most pepole but I
still find some aspects of 'import' a dark art so I thoguht I was
worth sticking it into the archives.

Thanks again for the tip.

Regards

Richard.



More information about the Python-list mailing list