73
73
return self.DEFAULT_SERVICE_URL
75
def get_proxy(self, authenticated):
76
76
"""Return the proxy for XMLRPC requests."""
77
# auth info must be in url
78
# TODO: if there's no registrant email perhaps we should just connect
80
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
81
assert '@' not in hostinfo
82
assert self.registrant_email is not None
83
assert self.registrant_password is not None
84
# TODO: perhaps fully quote the password to make it very slightly
86
# TODO: can we perhaps add extra Authorization headers directly to the
87
# request, rather than putting this into the url? perhaps a bit more
88
# secure against accidentally revealing it. std66 s3.2.1 discourages putting
89
# the password in the url.
90
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
91
urllib.quote(self.registrant_password),
93
url = urlunsplit((scheme, hostinfo, path, '', ''))
78
# auth info must be in url
79
# TODO: if there's no registrant email perhaps we should
80
# just connect anonymously?
81
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
82
assert '@' not in hostinfo
83
assert self.registrant_email is not None
84
assert self.registrant_password is not None
85
# TODO: perhaps fully quote the password to make it very slightly
87
# TODO: can we perhaps add extra Authorization headers
88
# directly to the request, rather than putting this into
89
# the url? perhaps a bit more secure against accidentally
90
# revealing it. std66 s3.2.1 discourages putting the
91
# password in the url.
92
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
93
urllib.quote(self.registrant_password),
95
url = urlunsplit((scheme, hostinfo, path, '', ''))
97
url = self.service_url
94
98
return xmlrpclib.ServerProxy(url, transport=self.transport)
96
100
def gather_user_credentials(self):
107
111
self.registrant_password = auth.get_password(scheme, hostinfo,
110
def send_request(self, method_name, method_params):
111
proxy = self.get_proxy()
114
def send_request(self, method_name, method_params, authenticated):
115
proxy = self.get_proxy(authenticated)
112
116
assert method_name
113
117
method = getattr(proxy, method_name)
145
150
:param service: LaunchpadService indicating where to send
146
151
the request and the authentication credentials.
148
return service.send_request(self._methodname, self._request_params())
153
return service.send_request(self._methodname, self._request_params(),
151
157
class DryRunLaunchpadService(LaunchpadService):
154
160
The dummy service does not need authentication.
157
def send_request(self, method_name, method_params):
163
def send_request(self, method_name, method_params, authenticated):
160
166
def gather_user_credentials(self):
216
222
# This must match the parameter tuple expected by Launchpad for this
218
224
return (self.branch_url, self.bug_id, '')
227
class ResolveLaunchpadPathRequest(BaseRequest):
228
"""Request to resolve the path component of an lp: URL."""
230
_methodname = 'resolve_lp_path'
231
_authenticated = False
233
def __init__(self, path):
237
def _request_params(self):
238
"""Return xmlrpc request parameters"""