root/galaxy-central/eggs/twill-0.9-py2.6.egg/twill/_browser.py @ 3

リビジョン 3, 1.2 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2A subclass of the mechanize browser patched to fix various bits.
3"""
4
5# wwwsearch imports
6from _mechanize_dist import Browser as MechanizeBrowser
7
8import wsgi_intercept
9from utils import FixedHTTPBasicAuthHandler, FunctioningHTTPRefreshProcessor
10
11def build_http_handler():
12    from _mechanize_dist._urllib2 import HTTPHandler
13
14    class MyHTTPHandler(HTTPHandler):
15        def http_open(self, req):
16            return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)
17
18    return MyHTTPHandler
19
20class PatchedMechanizeBrowser(MechanizeBrowser):
21    """
22    A patched version of the mechanize browser class.  Currently
23    installs the WSGI intercept handler & fixes a problem with
24    mechanize/urllib2 Basic Authentication.
25    """
26    def __init__(self, *args, **kwargs):
27        # install WSGI intercept handler.
28        self.handler_classes['http'] = build_http_handler()
29
30        # fix basic auth.
31        self.handler_classes['_basicauth'] = FixedHTTPBasicAuthHandler
32
33        # make refresh work even for somewhat mangled refresh directives.
34        self.handler_classes['_refresh'] = FunctioningHTTPRefreshProcessor
35
36        MechanizeBrowser.__init__(self, *args, **kwargs)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。