53
54
errors.BzrError.__init__(self, url=url)
57
class XMLRPCTransport(xmlrpclib.Transport):
59
def __init__(self, scheme, use_datetime=0):
60
xmlrpclib.Transport.__init__(self, use_datetime=use_datetime)
62
self._opener = _urllib2_wrappers.Opener()
65
def request(self, host, handler, request_body, verbose=0):
66
self.verbose = verbose
67
url = self._scheme + "://" + host + handler
68
request = _urllib2_wrappers.Request("POST", url, request_body)
69
# FIXME: _urllib2_wrappers will override user-agent with its own
70
# request.add_header("User-Agent", self.user_agent)
71
request.add_header("Content-Type", "text/xml")
73
response = self._opener.open(request)
74
if response.code != 200:
75
raise xmlrpclib.ProtocolError(host + handler, response.code,
76
response.msg, response.info())
77
return self.parse_response(response)
56
80
class LaunchpadService(object):
57
81
"""A service to talk to Launchpad via XMLRPC.
90
114
self._lp_instance = lp_instance
91
115
if transport is None:
92
116
uri_type = urllib.splittype(self.service_url)[0]
93
if uri_type == 'https':
94
transport = xmlrpclib.SafeTransport()
96
transport = xmlrpclib.Transport()
117
transport = XMLRPCTransport(uri_type)
97
118
transport.user_agent = 'bzr/%s (xmlrpclib/%s)' \
98
119
% (_bzrlib_version, xmlrpclib.__version__)
99
120
self.transport = transport