[twill] Twill is not working as expected

C. Titus Brown ctb at msu.edu
Sun Feb 1 21:29:21 PST 2009


On Wed, Jan 21, 2009 at 12:54:42AM +0200, Sergey Kishchenko wrote:
-> Hi,
-> 
-> I am trying to test Google OpenID Auth with twill, but getting an unexpected
-> URLError because of quotes in refresh url that google inserts in response's
-> header (Refresh: 0; url='http://www.google.com/...' , notice single quotes).
-> I don't know is it a google's bug or twill's feature :). I propose this
-> simple patch:
-> 
-> ---
-> /usr/lib/python2.5/site-packages/twill-0.9-py2.5.egg/twill/other_packages/_mechanize_dist/_request.py
-> 2009-01-21 00:34:17.000000000 +0200
-> +++ /home/sergey/dev/sandbox/_request.py    2009-01-21 00:25:35.000000000
-> +0200
-> @@ -31,7 +31,10 @@ class Request(urllib2.Request):
->          if not _rfc3986.is_clean_uri(url):
->              warn("url argument is not a URI "
->                   "(contains illegal characters) %r" % url)
-> -        urllib2.Request.__init__(self, url, data, headers)
-> +        if url[0]=="'" and url[-1]=="'":
-> +            url = url[1:-1]
-> +
-> +    urllib2.Request.__init__(self, url, data, headers)
->          self.selector = None
->          self.unredirected_hdrs = {}
->          self.visit = visit
-> 
-> Can anyone help me with not-so-dirty solution?

Hi, Sergey,

putting 

        url = url.strip("'")
	url = url.strip('"')

in seems to work.  I've added a test for this and changed the existing
twill code in svn at

	http://code.google.com/p/twill/

cheers,
--titus
-- 
C. Titus Brown, ctb at msu.edu



More information about the twill mailing list