problems with module Cookie
NOmanlio_perilloSPAM at libero.it
Tue Jun 1 10:33:05 CEST 2004
On 31 May 2004 01:56:10 +0100, jjl at pobox.com (John J. Lee) wrote:
>> I need cookies because the server (as many other) authenticate user
>> with cookies.
>> So the simple algorithm is:
>> -connect to the server
>> -read a cookie from a file
>> -send the cookie to the server
>> -if the server send a cookie, the old one must be updated: with
>> standard Cookie this is simple: cookie.update(newcookie)
>> - ...
>> - save the cookie to a file
>> This is very simple to do with httplib and Cookie modules, so why to
>> use more involved modules?
>No reason at all if you're happy with it, of course. That was what my
>"Cool" was meant to communicate.
>*Using* urllib2 is less involved even than your little algorithm
>above, of course (neglecting bugs, of course, including the persistent
>connection bug, which -- though it could certainly be a problem -- I
>confess has never actually troubled me, despite having used it to
>repeatedly fetch tens of millions of records in the past).
>Why use modules whose *implementation* is more involved? Because
>they're even easier to use, and because, even for simple scripts like
>your's, not every case is as simple as the one you happen to have met.
You are right, but: what means 'easier to use'?
There is less code to write?
There is less theory to learn?
For my script using urllib2 does not make the program easier.
>I know from experience that it can quickly get *very* tiresome to do
>some of this stuff by hand (even if only a few things like
>redirections and cookies are involved).
In my case cookie are very easy to use and I simply ignore
Of course I agree with you for all other cases, but there exist
programs that really needs only low level library.
Actually, ad example, standard Cookie module is low level.
It only parses key=value pairs, and, more important, it is 'other
That is, BaseCookie class has a parse method for parsing a string
(as SetCookie: key=value; ....), and an OutputString (added by me)
that returns the cookie data.
Thanks and regards Manlio Perillo
More information about the Python-list