[twill] wsgi_intercept, https and twill
Robert Leftwich
twill at rtl.fmailbox.com
Mon Jan 7 10:13:37 PST 2008
On Mon, 7 Jan 2008 11:19:15 -0600, "Kumar McMillan"
<kumar.mcmillan at gmail.com> said:
>
> yes, I'd like to add a section for that but I haven't had time to sit
> down with a default install of twill to try and get it working. If
> you get anything working, please let me know how!
Well, I have something that appears to work.... but is messy/fragile.
Firstly, I installed the latest wsgi_intercept and mechanize. The
install of mechanize also installs clientform v0.2,7.
I then moved the mechanize directory and ClientForm.py from
twill/other_packages to a safe place.
After this some twill tests ran ok but nothing form related worked, so I
replaced ClientForm.py in the ClientForm-0.2.7-py2.5.egg directory with
the older version from twill and the forms worked again.
However, nothing https related was working yet (i.e. the original
problem). Editing twill/_browser,py to add support for https, as shown
below, appears to work in limited testing:
...
class MyHTTPHandler(HTTPHandler):
def http_open(self, req):
return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)
https_open = http_open
return MyHTTPHandler
class PatchedMechanizeBrowser(MechanizeBrowser):
"""
A patched version of the mechanize browser class. Currently
installs the WSGI intercept handler & fixes a problem with
mechanize/urllib2 Basic Authentication.
"""
def __init__(self, *args, **kwargs):
# install WSGI intercept handler.
self.handler_classes['http'] = build_http_handler()
self.handler_classes['https'] = build_http_handler()
...
Of course, being new to the internals of twill this may not be complete,
but so far so good.... by some definition of good :-)
Robert
More information about the twill
mailing list