[Patches] [ python-Patches-523415 ] Explict proxies for urllib.urlopen()
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 04 Apr 2002 12:51:56 -0800
Patches item #523415, was opened at 2002-02-27 09:53
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=523415&group_id=5470
Category: Library (Lib)
Group: Python 2.2.x
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Andy Gimblett (gimbo)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Explict proxies for urllib.urlopen()
Initial Comment:
This patch extends urllib.urlopen() so that
proxies may be specified explicitly. This is
achieved by adding an optional "proxies"
parameter. If this parameter is omitted,
urlopen() acts exactly as before, ie gets
proxy settings from the environment.
This is useful if you want to tell urlopen()
not to use the proxy: just pass an empty
dictionary.
Also included is a patch to the urllib
documentation explaining the new parameter.
Apologies if patch format is not exactly as
required: this is my first submission. All
feedback appreciated. :-)
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-04-04 15:51
Message:
Logged In: YES
user_id=3066
I've checked this in, with some changes to the code for
urlopen(). When a proxy configuration is supplied, the
version I checked in does not save the opener if there isn't
one; it always discards it. If you really want to use a
specific proxy configuration with the simple functions,
create the opener and assign it to urllib._urlopener.
----------------------------------------------------------------------
Comment By: Andy Gimblett (gimbo)
Date: 2002-03-21 06:08
Message:
Logged In: YES
user_id=262849
OK, have updated docs as suggested by aimacintyre,
attached as urllib_proxies_docs.cdiff
I also added an example for explicit proxy
specification, since it illustrates how the proxies
dictionary should be structured.
----------------------------------------------------------------------
Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2002-03-10 00:31
Message:
Logged In: YES
user_id=250749
I think expanding the docs is the go here.
In looking at the 2.2 docs (11.4 urllib), the bits that I think could usefully be improved include:-
- the paragraph describing the proxy environment variables should note that on Windows,
browser (at least for InternetExplorer - I don't know about Netscape) registry settings for proxies
will be used when available;
- a short para noting that proxies can be overridden using URLopener/FancyURLopener
class instances, documented further down the page, placed just before the note about
not supporting authenticating proxies;
- adding a description of the "proxies" parameter to the URLopener class definition;
- adding an example of bypassing proxies to the examples subsection (11.4.2).
If/when you upload a doc patch, I suggest that you assign it to Fred Drake, who is the
chief docs person.
----------------------------------------------------------------------
Comment By: Andy Gimblett (gimbo)
Date: 2002-03-04 04:33
Message:
Logged In: YES
user_id=262849
Thanks for feedback re: diffs. Have now found out
about context diffs and attached new version - hope
this is better.
Regarding the patch itself, this arose out of a newbie
question on c.l.py and I was reminded that this was an
issue I'd come across in my early days too. Personally
I'd never picked up the hint that you should use
FancyURLopener directly.
If preferred, I could have a go at patching the docs
to make that clearer?
----------------------------------------------------------------------
Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2002-03-02 22:34
Message:
Logged In: YES
user_id=250749
BTW, the patch guidelines indicate a strong preference for context diffs with unified diffs a poor second.
----------------------------------------------------------------------
Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2002-03-02 22:32
Message:
Logged In: YES
user_id=250749
Having just looked at this myself, I can understand where you're coming from, however my reading between the lines of the
docs is that if you care about the proxies then you are supposed to use urllib.FancyURLopener (or urllib.URLopener)
directly. If this is the intent, the docs could be a little clearer about this.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=523415&group_id=5470