[twill] wsgi_intercept, https and twill

Titus Brown titus at caltech.edu
Wed Jan 9 01:43:21 PST 2008


On Mon, Jan 07, 2008 at 08:17:45PM +0000, John J Lee wrote:
-> On Tue, 8 Jan 2008, Robert Leftwich wrote:
-> [...]
-> > 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()
-> [...]
-> 
-> You're mutating a class attribute here -- not a good idea.

Understood.

It's a private copy of mechanize.Browser at this point, though, so it's
unlikely to matter.  I suppose I could copy this:

class Browser(UserAgentBase):
   handler_classes = copy.copy(UserAgentBase.handler_classes)

Is that the right way to go about it?

--titus



More information about the twill mailing list