def do_open(self, http_class, req): if self.proxy is not None: req.set_proxy(self.proxy, "http") return urllib2.HTTPHandler.do_open(self, ProxyHTTPConnection, req)