/usr/share/pyshared/twill/_browser.py is in python-twill 0.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | """
A subclass of the mechanize browser patched to fix various bits.
"""
# wwwsearch imports
from mechanize import Browser as MechanizeBrowser
import wsgi_intercept
from utils import FixedHTTPBasicAuthHandler, FunctioningHTTPRefreshProcessor
def build_http_handler():
from mechanize._urllib2 import HTTPHandler
class MyHTTPHandler(HTTPHandler):
def http_open(self, req):
return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)
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()
# fix basic auth.
self.handler_classes['_basicauth'] = FixedHTTPBasicAuthHandler
# make refresh work even for somewhat mangled refresh directives.
self.handler_classes['_refresh'] = FunctioningHTTPRefreshProcessor
MechanizeBrowser.__init__(self, *args, **kwargs)
|