root/galaxy-central/eggs/twill-0.9-py2.6.egg/twill/other_packages/_mechanize_dist/_upgrade.py

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

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

行番号 
1from urllib2 import BaseHandler
2
3from _request import Request
4from _response import upgrade_response
5from _util import deprecation
6
7
8class HTTPRequestUpgradeProcessor(BaseHandler):
9    # upgrade urllib2.Request to this module's Request
10    # yuck!
11    handler_order = 0  # before anything else
12
13    def http_request(self, request):
14        if not hasattr(request, "add_unredirected_header"):
15            newrequest = Request(request._Request__original, request.data,
16                                 request.headers)
17            try: newrequest.origin_req_host = request.origin_req_host
18            except AttributeError: pass
19            try: newrequest.unverifiable = request.unverifiable
20            except AttributeError: pass
21            try: newrequest.visit = request.visit
22            except AttributeError: pass
23            request = newrequest
24        return request
25
26    https_request = http_request
27
28
29class ResponseUpgradeProcessor(BaseHandler):
30    # upgrade responses to be .close()able without becoming unusable
31    handler_order = 0  # before anything else
32
33    def __init__(self):
34        deprecation(
35            "See http://wwwsearch.sourceforge.net/mechanize/doc.html#seekable")
36
37    def any_response(self, request, response):
38        if not hasattr(response, 'closeable_response'):
39            response = upgrade_response(response)
40        return response
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。