53
54
errors.BzrError.__init__(self, url=url)
57
class XMLRPCTransport(xmlrpclib.Transport):
59
def __init__(self, scheme):
60
# In python2.4 xmlrpclib.Transport is a old-style class, and does not
61
# define __init__, so we check first
62
init = getattr(xmlrpclib.Transport, '__init__', None)
66
self._opener = _urllib2_wrappers.Opener()
69
def request(self, host, handler, request_body, verbose=0):
70
self.verbose = verbose
71
url = self._scheme + "://" + host + handler
72
request = _urllib2_wrappers.Request("POST", url, request_body)
73
# FIXME: _urllib2_wrappers will override user-agent with its own
74
# request.add_header("User-Agent", self.user_agent)
75
request.add_header("Content-Type", "text/xml")
77
response = self._opener.open(request)
78
if response.code != 200:
79
raise xmlrpclib.ProtocolError(host + handler, response.code,
80
response.msg, response.info())
81
return self.parse_response(response)
56
84
class LaunchpadService(object):
57
85
"""A service to talk to Launchpad via XMLRPC.
90
118
self._lp_instance = lp_instance
91
119
if transport is None:
92
120
uri_type = urllib.splittype(self.service_url)[0]
93
if uri_type == 'https':
94
transport = xmlrpclib.SafeTransport()
96
transport = xmlrpclib.Transport()
121
transport = XMLRPCTransport(uri_type)
97
122
transport.user_agent = 'bzr/%s (xmlrpclib/%s)' \
98
123
% (_bzrlib_version, xmlrpclib.__version__)
99
124
self.transport = transport