/usr/share/pyshared/wsgi_intercept/mechanize_intercept/wsgi_browser.py is in python-wsgi-intercept 0.4-0ubuntu3.
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 | """
A mechanize browser that redirects specified HTTP connections to a WSGI
object.
"""
from httplib import HTTP
from mechanize import Browser as MechanizeBrowser
from wsgi_intercept.urllib2_intercept import install_opener, uninstall_opener
try:
from mechanize import HTTPHandler
except ImportError:
# pre mechanize 0.1.0 it was a separate package
# (this will break if it is combined with a newer mechanize)
from ClientCookie import HTTPHandler
import sys, os.path
from wsgi_intercept.urllib2_intercept import WSGI_HTTPHandler, WSGI_HTTPSHandler
class Browser(MechanizeBrowser):
"""
A version of the mechanize browser class that
installs the WSGI intercept handler
"""
handler_classes = MechanizeBrowser.handler_classes.copy()
handler_classes['http'] = WSGI_HTTPHandler
handler_classes['https'] = WSGI_HTTPSHandler
def __init__(self, *args, **kwargs):
# install WSGI intercept handler.
install(self)
MechanizeBrowser.__init__(self, *args, **kwargs)
def install(browser):
install_opener()
|