Re: [wwwsearch-general] Re: Urllib2 / add_password method



On Sat, 29 Apr 2006, John J. Lee wrote:

"mrstephengross" <mrstephengross@xxxxxxxxxxx> writes:

I'm working on learning how to use urllib2 to use a proxy server. I've
looked through the postings on this group, and it's been helpful. I
have not, however, found complete documentation on the add_password()
functions. Here's what I've got so far:

Don't use a password manager with proxy auth in 2.4, it doesn't work:

http://python.org/sf/1470846

[...]
It works, but I don't really know what I'm doing with the
proxy_auth_handler part. Specifying username and password make sense,
but I haven't found documentation on what 'realm' and 'host' are for.
Shouldn't username & password be sufficient?

Oops, didn't read your question.

I'm surprised if it worked at all given that bug (maybe you're using an older Python, and I forget all the details of the bug).

Anyway, to answer your question: yes, username & password *should* be sufficient, but the password manager classes in urllib2 at present aren't very friendly like that. You can use HTTPPasswordMgrWithDefaultRealm so that at least you can forget about the realm part. (The "realm" is what you see in the title bar of the pop-up that web browsers display. See RFC 2617 for more details.)

I'm adding friendlier proxy/auth support to package mechanize ATM (and finding/fixing bugs as I go), so maybe some of that will find its way into Python 2.6.


John

.



Relevant Pages

  • Weekly Python Patch/Bug Summary
    ... Patch / Bug Summary ... Help with Python codebase ... Update to Macintosh library documentation ... Segfaults on memory error ...
    (comp.lang.python)
  • Weekly Python Patch/Bug Summary
    ... Patch / Bug Summary ... typo in liblocale.tex ... subprocess documentation ... Registry not updated by 2.4b1 installer ...
    (comp.lang.python)
  • Re: Tired of 100s of stupid Getter/Setter methods
    ... > reading the documentation that the library developer wrote. ... ability to become familiar with an API. ... Given the choice between finding out about a bug as I'm writing the ... say about a language that's one of the more readable that I work in. ...
    (comp.lang.java.programmer)
  • Re: strtomember and strtoset bug with hyphen
    ... I fully agree with you that the documentation should've been much clearer in ... As I explained, this cannot be considered as bug, because "-" and other ... reserved keyword as the member name without quoting it. ... >> You should either quote the special characters, ...
    (microsoft.public.sqlserver.olap)
  • Weekly Python Patch/Bug Summary
    ... optparse documentation bug fixes ... http://python.org/sf/1203329 closed by loewis ... http://python.org/sf/967182 closed by montanaro ...
    (comp.lang.python)