[Web-SIG] urllib package addressing PEP 3108

O.R.Senthil Kumaran orsenthil at gmail.com
Wed Jun 18 20:03:32 CEST 2008


Hi Facundo,

* Facundo Batista <facundobatista at gmail.com> [2008-06-18 14:52:46]:
> 
> I think Jeremy will handle this today...


I got in touch with Jeremy and we both are working together. :-)
Currently there are 4 urllib tests still failing. Trying to sort things out.
We discussed upon the split-up and other details like single urlopen method.

Things are working out good. 

Thanks,
Senthil


> > 1) urlopen method. Both urllib.py and urllib2.py currently have this method,
> > urllib one takes proxies as the last argument and urllib2 takes timeout as the
> > last argument.
> > How do we have both of them?
> >
> > My thought, have urllib2's urlopen, because it anyway provides the proxy
> > handling through handlers and discard urllib's urlopen method.
> >
> > Comments please?
> 
> Which would be the drawback of accepting the proxies directly in the
> urlopen() function?
> 
> Right now, to use a proxy I do:
> 
> proxy = urllib2.ProxyHandler({"http":"http://www.norealproxy.com:8080"})
> opener = urllib2.build_opener(proxy, urllib2.HTTPHandler)
> urllib2.install_opener(opener)
> def ericsson_urlopen(*args):
>     return urllib2.urlopen(*args)
> 
> Maybe I could use the syntax of urllib.urlopen(), and that it
> automatically to do that?

We settled upon using urllib2's urlopen method. The difference between
urllib's urlopen and urllib2's urlopen was, both returned add_info_url()
objects with urlopen wrapping up http client response class and urllib2
wrapping it up in io.Buffered.Reader

So, the settlement was: use urlopen from urllib2, but wrap it in http client
class for the file like object so that things get handled for both.

The bugs in test were mostly due to this and is being fixed.

Thanks,
Senthil



> > Now, splitting the methods to request.py and parse.py
> >
> > request.py - urlopen (urllib2's), URLopener, FancyURLopener, urlretrieve,
> >             urlcleanup, localhost, thishost, ftperrors, getproxies.
> >
> > parse.py -   quote, quote_plus, unquote, unquote_plus, urlencode, url2pathname,
> >             pathname2url, splittag,basejoin,unwrap,splittype,splithost,
> >             splituser, splitpasswd, splitport,splitnport,splitquery,splitattr,              splitvalue
> 
> +1
> 
> Regards,
> 
> -- 
> . Facundo
> 
> Blog: http://www.taniquetil.com.ar/plog/
> PyAr: http://www.python.org/ar/

-- 
O.R.Senthil Kumaran
http://uthcode.sarovar.org


More information about the Web-SIG mailing list