[Web-SIG] WSGI URLOpener

Ian Bicking ianb at colorstudy.com
Wed Apr 27 00:43:00 CEST 2005


Just an idea I'll put out, in case anyone finds it interesting...

A WSGI opener for urllib2 would be interesting.  I imagine using it like:

   import urllib2
   import wsgiurl

   myapp = construct_app()

   wsgiurl.register_app('myapp', myapp)
   f = urllib2.urlopen('wsgi:myapp/login')

and so on.  Then things like PBP and Twill could, I think, be run on top 
of an in-process WSGI application.  Though I suspect that some of these 
might like like the wsgi: scheme...?  If so, an option like:

   wsgiurl.register_app('myapp', myapp, scheme='http')
   f = urllib2.urlopen('http://myapp/login')

Would be useful.  This would probably require some monkeypatching of 
urllib2 to intercept calls to some domains.

Either way, this makes functional and acceptance testing easier and 
faster to perform (since there's no server setup), and means that the 
same tools can easily be used for both in-process and remote testing. 
Anyway, I think it would be neat, and maybe one of you guys will think 
it's a neat idea and implement it...? ;)

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org


More information about the Web-SIG mailing list