[Inteproxy-commits] r81 - in trunk: . inteproxy

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 4 19:47:56 CEST 2007


Author: bh
Date: 2007-05-04 19:47:56 +0200 (Fri, 04 May 2007)
New Revision: 81

Modified:
   trunk/ChangeLog
   trunk/inteproxy/main.py
Log:
* inteproxy/main.py (setup_urllib2): Build a list of handlers
incrementatlly so that we can call build_opener in once place
instead of two.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-02 15:57:18 UTC (rev 80)
+++ trunk/ChangeLog	2007-05-04 17:47:56 UTC (rev 81)
@@ -1,3 +1,9 @@
+2007-05-04  Bernhard Herzog  <bh at intevation.de>
+
+	* inteproxy/main.py (setup_urllib2): Build a list of handlers
+	incrementatlly so that we can call build_opener in once place
+	instead of two.
+
 2007-05-02  Bernhard Herzog  <bh at intevation.de>
 
 	* inteproxy/feesdialog.py (handle_fees_and_access_constraints):

Modified: trunk/inteproxy/main.py
===================================================================
--- trunk/inteproxy/main.py	2007-05-02 15:57:18 UTC (rev 80)
+++ trunk/inteproxy/main.py	2007-05-04 17:47:56 UTC (rev 81)
@@ -35,24 +35,22 @@
         return user, password
 
 def setup_urllib2(debuglevel):
-    auth_handler = urllib2.HTTPBasicAuthHandler(IntePasswordManager())
+    handlers = [urllib2.HTTPBasicAuthHandler(IntePasswordManager())]
     if os.environ.has_key('https_proxy'):
         https_proxy = urlparse.urlsplit(os.getenv('https_proxy'))[1]
         del os.environ['https_proxy']
         sys.stderr.write("[%s] Using HTTPS proxy: %s\n"
                          % (log_date_time_string(), https_proxy))
-        opener = urllib2.build_opener(
-            auth_handler,
+        handlers.extend((
             proxyconnection.ConnectHTTPHandler(proxy=https_proxy,
                                                debuglevel=debuglevel),
             proxyconnection.ConnectHTTPSHandler(proxy=https_proxy,
-                                                debuglevel=debuglevel))
+                                                debuglevel=debuglevel)))
     else:
         httphandler = urllib2.HTTPHandler(debuglevel=debuglevel)
         httpshandler = urllib2.HTTPSHandler(debuglevel=debuglevel)
-        opener = urllib2.build_opener(auth_handler, httphandler,
-                                      httpshandler)
-    urllib2.install_opener(opener)
+        handlers.extend((httphandler, httpshandler))
+    urllib2.install_opener(urllib2.build_opener(*handlers))
 
 
 # The main application object.  It's a global variable so that worker



More information about the Inteproxy-commits mailing list