[Patches] [Patch #100873] Use registry to find proxies for urllib on Win32

noreply@sourceforge.net noreply@sourceforge.net
Tue, 25 Jul 2000 23:47:47 -0700


Patch #100873 has been updated. 

Project: 
Category: None
Status: Accepted
Summary: Use registry to find proxies for urllib on Win32

Follow-Ups:

Date: 2000-Jul-12 19:27
By: gvanrossum

Comment:
Mark, can you have a look at this? If it's okay, pass it on to Tim. If you don't have time, assign it to Greg.

One immediate problem: a huge block of hairy code inside an unqualified try-except is a no-no!
-------------------------------------------------------

Date: 2000-Jul-13 07:45
By: moshez

Comment:
I think that if you change the "except", to "except whatever_error_winreg_raises" it should be all right
-------------------------------------------------------

Date: 2000-Jul-13 07:57
By: mhammond

Comment:
Im happy with this patch.  I'll be back in Oz in a week - I will test and approve the patch then - if this delay is a problem, I'm happy for it to be re-assigned.
-------------------------------------------------------

Date: 2000-Jul-15 01:07
By: btutt

Comment:
Its not that simple....
See KB #Q226473 that spells out all of the relavent details about why this is a not so good idea:

http://support.microsoft.com/support/kb/articles/Q226/4/73.ASP



-------------------------------------------------------

Date: 2000-Jul-15 18:59
By: mhammond

Comment:
OK - so it wont be perfect - but are you suggesting that this patch is not an improvement?  Even after reading that page, I'm inclined to suggest it is better than the code we have now.
-------------------------------------------------------

Date: 2000-Jul-17 16:46
By: btutt

Comment:
Its better than we have now, but I defiantely dislike using the registry to acquire data when theres an API that exposes the same data. 

-------------------------------------------------------

Date: 2000-Jul-23 21:50
By: mhammond

Comment:
I agree with Bill's comments, although there is no clear place to put the C code necessary to do this.  Further, the point about multiple proxy settings isnt that useful, as we can not predict what internet connection should be used for the proxy settings - we don't have much choice other than to use the default.

However, I just confirmed that Mozilla, for example, doesnt use this registry key.  I assume that Netscape 4.x also doesnt (but I don't have that installed - does anyone know?) So in effect, we are providing a patch that will allow IE users to have their proxy configuration for their default connection to be used.

For non IE users, this patch is a problem, as it provides no technique for overriding the (presumably empty) registry.  And for IE users with multiple connections, this may not be what they want (and allowing Python to select which connection via some GUI is definately beyond the scope of this patch)

I propose that the patch be modified to allow the existing scheme of environment variables, and to only go sniffing the registry if this variable doesnt exist.  This will allow _anyone_ to set a variable to get their specific preference at any time, while still allowing the majority of users (ie, IE users with a single internet connection) to not specify this variable, but still work.

Comments please!
-------------------------------------------------------

Date: 2000-Jul-23 23:26
By: nyamatongwe

Comment:
The Navigator/Mozilla proxy information is found in the prefs.js file in the preferred profile directory. The default profile is named "default". It looks like:

user_pref("network.proxy.http", "127.0.0.1");
user_pref("network.proxy.http_port", 8080);
user_pref("network.proxy.type", 1);

Not worth the fiddling IMHO.

This registry key is not just for IE, as it is used by other applications such as WinAmp but this may only be read at install-time. You can change the settings in the Internet Options applet inside the Control Panel.

Looking in the environment first is fine.
-------------------------------------------------------

Date: 2000-Jul-24 00:36
By: mhammond

Comment:
I agree with Bill's comments, although there is no clear place to put the C code necessary to do this.  Further, the point about multiple proxy settings isnt that useful, as we can not predict what internet connection should be used for the proxy settings - we don't have much choice other than to use the default.

However, I just confirmed that Mozilla, for example, doesnt use this registry key.  I assume that Netscape 4.x also doesnt (but I don't have that installed - does anyone know?) So in effect, we are providing a patch that will allow IE users to have their proxy configuration for their default connection to be used.

For non IE users, this patch is a problem, as it provides no technique for overriding the (presumably empty) registry.  And for IE users with multiple connections, this may not be what they want (and allowing Python to select which connection via some GUI is definately beyond the scope of this patch)

I propose that the patch be modified to allow the existing scheme of environment variables, and to only go sniffing the registry if this variable doesnt exist.  This will allow _anyone_ to set a variable to get their specific preference at any time, while still allowing the majority of users (ie, IE users with a single internet connection) to not specify this variable, but still work.

Comments please!
-------------------------------------------------------

Date: 2000-Jul-24 16:16
By: mhammond

Comment:
As discussed, this version uses the environment, and failing that, the registry.

The patch is now a little more intrusive in an attempt to avoid cut-and-paste of the environment logic.  It is now also trivial for the Mac to also use the same "environment first" trick, but I havent touched that!

Has been tested on Windows and vaguely tested on Debian Linux.  Re-assigned to Tim, so he can check the style etc (eg, there is one line that _just_ reaches over 80 chars, and IMO is far more ugly to fix than to leave).  Tim - feel free to reassign back and I will make corrections and checkin if necessary (although Guido explicitly asked that it be assigned to you - obviously you need more work thrown at you <wink>).
-------------------------------------------------------

Date: 2000-Jul-25 23:47
By: tim_one

Comment:
Accepted & assigned back to Mark.  I don't know anything about proxies, so I didn't review that.  Style looks OK to me, and I agree the "long line" isn't an unforgivable sin in this case.  One suggestion:
x    ... name[-6:] == '_proxy'
is clearer as
x    ... name.endswith('_proxy')
Unfortunately, the hard-coded 6 on the line following that one is harder to get rid of.

I'd sure like to see more testing on Linux, but maybe checking it in is the best way to make that happen!

-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=100873&group_id=5470