~bzr-pqm/bzr/bzr.dev

5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
1
# Copyright (C) 2006-2011 Canonical Ltd
0.4.4 by Martin Pool
Start forming xmlrpc requests
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
0.4.4 by Martin Pool
Start forming xmlrpc requests
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.4.4 by Martin Pool
Start forming xmlrpc requests
16
17
0.4.17 by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL
18
import os
4505.4.1 by Jonathan Lange
Trap gaierror and reraise appropriate ConnectionError.
19
import socket
0.4.7 by Martin Pool
Start making provision to test using a mock xmlrpc transport.
20
from urlparse import urlsplit, urlunsplit
0.4.29 by Martin Pool
(register-branch) override xmlrpc user-agent; move Transport construction
21
import urllib
0.4.4 by Martin Pool
Start forming xmlrpc requests
22
import xmlrpclib
0.4.13 by Martin Pool
Update xmlrpc api to pass product name as a parameter.
23
2900.2.21 by Vincent Ladeuil
Make lp_registration aware of authentication config.
24
from bzrlib import (
25
    config,
26
    errors,
4505.6.3 by Jonathan Lange
Don't bother lazy importing.
27
    urlutils,
2900.2.22 by Vincent Ladeuil
Polishing.
28
    __version__ as _bzrlib_version,
2900.2.21 by Vincent Ladeuil
Make lp_registration aware of authentication config.
29
    )
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
30
from bzrlib.transport.http import _urllib2_wrappers
1668.1.9 by Martin Pool
(launchpad plugin) Better reporting of errors from xmlrpc
31
4505.6.5 by Jonathan Lange
Factor out some code that guesses a branch's URL.
32
1668.1.9 by Martin Pool
(launchpad plugin) Better reporting of errors from xmlrpc
33
# for testing, do
34
'''
35
export BZR_LP_XMLRPC_URL=http://xmlrpc.staging.launchpad.net/bazaar/
36
'''
0.4.13 by Martin Pool
Update xmlrpc api to pass product name as a parameter.
37
3193.5.2 by Tim Penhey
Updated the tests to handle unknown launchpad instances.
38
class InvalidLaunchpadInstance(errors.BzrError):
39
40
    _fmt = "%(lp_instance)s is not a valid Launchpad instance."
41
42
    def __init__(self, lp_instance):
43
        errors.BzrError.__init__(self, lp_instance=lp_instance)
44
45
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
46
class NotLaunchpadBranch(errors.BzrError):
47
4031.2.8 by Jonathan Lange
Say "registered on", not "hosted on".
48
    _fmt = "%(url)s is not registered on Launchpad."
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
49
50
    def __init__(self, url):
51
        errors.BzrError.__init__(self, url=url)
52
53
4776.2.6 by Vincent Ladeuil
Fixed as per review comments.
54
class XMLRPCTransport(xmlrpclib.Transport):
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
55
4776.3.1 by Vincent Ladeuil
Fix python2.4 compatibility with xmlrpclib.
56
    def __init__(self, scheme):
4776.3.2 by John Arbash Meinel
Clarify the comment as to why we are checking __init__
57
        # In python2.4 xmlrpclib.Transport is a old-style class, and does not
58
        # define __init__, so we check first
4776.3.1 by Vincent Ladeuil
Fix python2.4 compatibility with xmlrpclib.
59
        init = getattr(xmlrpclib.Transport, '__init__', None)
60
        if init is not None:
61
            init(self)
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
62
        self._scheme = scheme
63
        self._opener = _urllib2_wrappers.Opener()
64
        self.verbose = 0
65
66
    def request(self, host, handler, request_body, verbose=0):
67
        self.verbose = verbose
68
        url = self._scheme + "://" + host + handler
69
        request = _urllib2_wrappers.Request("POST", url, request_body)
4776.2.4 by Vincent Ladeuil
Note that User-Agent is lost (we use the bzrlib one though).
70
        # FIXME: _urllib2_wrappers will override user-agent with its own
71
        # request.add_header("User-Agent", self.user_agent)
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
72
        request.add_header("Content-Type", "text/xml")
73
74
        response = self._opener.open(request)
75
        if response.code != 200:
76
            raise xmlrpclib.ProtocolError(host + handler, response.code,
77
                                          response.msg, response.info())
78
        return self.parse_response(response)
79
80
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
81
class LaunchpadService(object):
0.4.27 by Martin Pool
doc
82
    """A service to talk to Launchpad via XMLRPC.
3193.5.2 by Tim Penhey
Updated the tests to handle unknown launchpad instances.
83
4988.4.2 by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing
84
    See http://wiki.bazaar.canonical.com/Specs/LaunchpadRpc for the methods we can call.
0.4.27 by Martin Pool
doc
85
    """
0.4.6 by Martin Pool
Put the rest of the parameters into the registration request.
86
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
87
    LAUNCHPAD_DOMAINS = {
88
        'production': 'launchpad.net',
89
        'staging': 'staging.launchpad.net',
5615.2.1 by Jelmer Vernooij
Support the 'qastaging' instance of Launchpad.
90
        'qastaging': 'qastaging.launchpad.net',
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
91
        'demo': 'demo.launchpad.net',
92
        'dev': 'launchpad.dev',
93
        }
94
3211.1.1 by Ian Clatworthy
Extends the launchpad plugin's implementation of lp spec urls (Tim Penhey)
95
    # NB: these should always end in a slash to avoid xmlrpclib appending
0.4.7 by Martin Pool
Start making provision to test using a mock xmlrpc transport.
96
    # '/RPC2'
3955.3.2 by Jonathan Lange
Tighten up the code a little, changing the dev service to use https,
97
    LAUNCHPAD_INSTANCE = {}
98
    for instance, domain in LAUNCHPAD_DOMAINS.iteritems():
99
        LAUNCHPAD_INSTANCE[instance] = 'https://xmlrpc.%s/bazaar/' % domain
100
4634.165.3 by Vincent Ladeuil
Delete all references to edge.launchpad.net in code and associated tests.
101
    # We use production as the default because edge has been deprecated circa
102
    # 2010-11 (see bug https://bugs.launchpad.net/bzr/+bug/583667)
5243.1.1 by Martin
Use the production server in the launchpad plugin rather than edge
103
    DEFAULT_INSTANCE = 'production'
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
104
    DEFAULT_SERVICE_URL = LAUNCHPAD_INSTANCE[DEFAULT_INSTANCE]
0.4.13 by Martin Pool
Update xmlrpc api to pass product name as a parameter.
105
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
106
    transport = None
107
    registrant_email = None
108
    registrant_password = None
109
0.4.29 by Martin Pool
(register-branch) override xmlrpc user-agent; move Transport construction
110
3193.5.1 by Tim Penhey
Mostly working, just need to update the tests for lp://dev
111
    def __init__(self, transport=None, lp_instance=None):
0.4.23 by Martin Pool
(register-branch) fix ordering of parameters and restore transport-level test.
112
        """Construct a new service talking to the launchpad rpc server"""
3193.5.1 by Tim Penhey
Mostly working, just need to update the tests for lp://dev
113
        self._lp_instance = lp_instance
0.4.29 by Martin Pool
(register-branch) override xmlrpc user-agent; move Transport construction
114
        if transport is None:
115
            uri_type = urllib.splittype(self.service_url)[0]
4776.2.6 by Vincent Ladeuil
Fixed as per review comments.
116
            transport = XMLRPCTransport(uri_type)
0.4.29 by Martin Pool
(register-branch) override xmlrpc user-agent; move Transport construction
117
            transport.user_agent = 'bzr/%s (xmlrpclib/%s)' \
2900.2.22 by Vincent Ladeuil
Polishing.
118
                    % (_bzrlib_version, xmlrpclib.__version__)
0.4.29 by Martin Pool
(register-branch) override xmlrpc user-agent; move Transport construction
119
        self.transport = transport
120
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
121
    @property
122
    def service_url(self):
123
        """Return the http or https url for the xmlrpc server.
124
125
        This does not include the username/password credentials.
126
        """
127
        key = 'BZR_LP_XMLRPC_URL'
128
        if key in os.environ:
129
            return os.environ[key]
3193.5.1 by Tim Penhey
Mostly working, just need to update the tests for lp://dev
130
        elif self._lp_instance is not None:
3193.5.2 by Tim Penhey
Updated the tests to handle unknown launchpad instances.
131
            try:
132
                return self.LAUNCHPAD_INSTANCE[self._lp_instance]
133
            except KeyError:
134
                raise InvalidLaunchpadInstance(self._lp_instance)
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
135
        else:
136
            return self.DEFAULT_SERVICE_URL
137
4505.6.2 by Jonathan Lange
Extract a method that gets a service from a URL.
138
    @classmethod
139
    def for_url(cls, url, **kwargs):
140
        """Return the Launchpad service corresponding to the given URL."""
141
        result = urlsplit(url)
142
        lp_instance = result[1]
143
        if lp_instance == '':
144
            lp_instance = None
145
        elif lp_instance not in cls.LAUNCHPAD_INSTANCE:
146
            raise errors.InvalidURL(path=url)
147
        return cls(lp_instance=lp_instance, **kwargs)
148
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
149
    def get_proxy(self, authenticated):
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
150
        """Return the proxy for XMLRPC requests."""
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
151
        if authenticated:
152
            # auth info must be in url
153
            # TODO: if there's no registrant email perhaps we should
154
            # just connect anonymously?
155
            scheme, hostinfo, path = urlsplit(self.service_url)[:3]
3376.2.4 by Martin Pool
Remove every assert statement from bzrlib!
156
            if '@' in hostinfo:
157
                raise AssertionError(hostinfo)
158
            if self.registrant_email is None:
159
                raise AssertionError()
160
            if self.registrant_password is None:
161
                raise AssertionError()
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
162
            # TODO: perhaps fully quote the password to make it very slightly
163
            # obscured
164
            # TODO: can we perhaps add extra Authorization headers
165
            # directly to the request, rather than putting this into
166
            # the url?  perhaps a bit more secure against accidentally
167
            # revealing it.  std66 s3.2.1 discourages putting the
168
            # password in the url.
169
            hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
170
                                     urllib.quote(self.registrant_password),
171
                                     hostinfo)
172
            url = urlunsplit((scheme, hostinfo, path, '', ''))
173
        else:
174
            url = self.service_url
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
175
        return xmlrpclib.ServerProxy(url, transport=self.transport)
176
177
    def gather_user_credentials(self):
178
        """Get the password from the user."""
2978.5.1 by John Arbash Meinel
Fix bug #162494, 'bzr register-branch' needs proper auth handling.
179
        the_config = config.GlobalConfig()
180
        self.registrant_email = the_config.user_email()
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
181
        if self.registrant_password is None:
2900.2.21 by Vincent Ladeuil
Make lp_registration aware of authentication config.
182
            auth = config.AuthenticationConfig()
183
            scheme, hostinfo = urlsplit(self.service_url)[:2]
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
184
            prompt = 'launchpad.net password for %s: ' % \
185
                    self.registrant_email
2900.2.21 by Vincent Ladeuil
Make lp_registration aware of authentication config.
186
            # We will reuse http[s] credentials if we can, prompt user
187
            # otherwise
188
            self.registrant_password = auth.get_password(scheme, hostinfo,
2978.5.1 by John Arbash Meinel
Fix bug #162494, 'bzr register-branch' needs proper auth handling.
189
                                                         self.registrant_email,
2900.2.21 by Vincent Ladeuil
Make lp_registration aware of authentication config.
190
                                                         prompt=prompt)
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
191
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
192
    def send_request(self, method_name, method_params, authenticated):
193
        proxy = self.get_proxy(authenticated)
0.4.21 by Martin Pool
Refactor BaseRequest.submit so details of submission are in the LaunchpadService
194
        method = getattr(proxy, method_name)
1668.1.9 by Martin Pool
(launchpad plugin) Better reporting of errors from xmlrpc
195
        try:
196
            result = method(*method_params)
197
        except xmlrpclib.ProtocolError, e:
198
            if e.errcode == 301:
199
                # TODO: This can give a ProtocolError representing a 301 error, whose
200
                # e.headers['location'] tells where to go and e.errcode==301; should
201
                # probably log something and retry on the new url.
202
                raise NotImplementedError("should resend request to %s, but this isn't implemented"
203
                        % e.headers.get('Location', 'NO-LOCATION-PRESENT'))
204
            else:
205
                # we don't want to print the original message because its
206
                # str representation includes the plaintext password.
207
                # TODO: print more headers to help in tracking down failures
208
                raise errors.BzrError("xmlrpc protocol error connecting to %s: %s %s"
209
                        % (self.service_url, e.errcode, e.errmsg))
4505.4.1 by Jonathan Lange
Trap gaierror and reraise appropriate ConnectionError.
210
        except socket.gaierror, e:
211
            raise errors.ConnectionError(
212
                "Could not resolve '%s'" % self.domain,
213
                orig_error=e)
0.4.21 by Martin Pool
Refactor BaseRequest.submit so details of submission are in the LaunchpadService
214
        return result
215
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
216
    @property
217
    def domain(self):
218
        if self._lp_instance is None:
219
            instance = self.DEFAULT_INSTANCE
220
        else:
221
            instance = self._lp_instance
222
        return self.LAUNCHPAD_DOMAINS[instance]
223
4505.6.5 by Jonathan Lange
Factor out some code that guesses a branch's URL.
224
    def _guess_branch_path(self, branch_url, _request_factory=None):
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
225
        scheme, hostinfo, path = urlsplit(branch_url)[:3]
3955.3.8 by Jonathan Lange
Support lp URL shortcuts.
226
        if _request_factory is None:
227
            _request_factory = ResolveLaunchpadPathRequest
228
        if scheme == 'lp':
229
            resolve = _request_factory(path)
3955.3.9 by Jonathan Lange
Catch errors.
230
            try:
231
                result = resolve.submit(self)
232
            except xmlrpclib.Fault, fault:
233
                raise errors.InvalidURL(branch_url, str(fault))
3955.3.8 by Jonathan Lange
Support lp URL shortcuts.
234
            branch_url = result['urls'][0]
235
            path = urlsplit(branch_url)[2]
236
        else:
237
            domains = (
238
                'bazaar.%s' % domain
239
                for domain in self.LAUNCHPAD_DOMAINS.itervalues())
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
240
            if hostinfo not in domains:
241
                raise NotLaunchpadBranch(branch_url)
4505.6.5 by Jonathan Lange
Factor out some code that guesses a branch's URL.
242
        return path.lstrip('/')
243
244
    def get_web_url_from_branch_url(self, branch_url, _request_factory=None):
245
        """Get the Launchpad web URL for the given branch URL.
246
247
        :raise errors.InvalidURL: if 'branch_url' cannot be identified as a
248
            Launchpad branch URL.
249
        :return: The URL of the branch on Launchpad.
250
        """
251
        path = self._guess_branch_path(branch_url, _request_factory)
3955.3.7 by Jonathan Lange
Test the launchpad-open command. Fix up some minor bugs.
252
        return urlutils.join('https://code.%s' % self.domain, path)
3955.3.1 by Jonathan Lange
Start doing URL stuff, extracting the domain bit out of LaunchpadService,
253
0.4.21 by Martin Pool
Refactor BaseRequest.submit so details of submission are in the LaunchpadService
254
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
255
class BaseRequest(object):
256
    """Base request for talking to a XMLRPC server."""
257
258
    # Set this to the XMLRPC method name.
259
    _methodname = None
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
260
    _authenticated = True
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
261
262
    def _request_params(self):
263
        """Return the arguments to pass to the method"""
264
        raise NotImplementedError(self._request_params)
265
266
    def submit(self, service):
0.4.21 by Martin Pool
Refactor BaseRequest.submit so details of submission are in the LaunchpadService
267
        """Submit request to Launchpad XMLRPC server.
268
269
        :param service: LaunchpadService indicating where to send
270
            the request and the authentication credentials.
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
271
        """
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
272
        return service.send_request(self._methodname, self._request_params(),
273
                                    self._authenticated)
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
274
275
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
276
class DryRunLaunchpadService(LaunchpadService):
277
    """Service that just absorbs requests without sending to server.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
278
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
279
    The dummy service does not need authentication.
280
    """
281
2898.4.1 by James Henstridge
Make it possible to make unauthenticated XML-RPC requests.
282
    def send_request(self, method_name, method_params, authenticated):
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
283
        pass
284
285
    def gather_user_credentials(self):
286
        pass
287
288
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
289
class BranchRegistrationRequest(BaseRequest):
290
    """Request to tell Launchpad about a bzr branch."""
291
292
    _methodname = 'register_branch'
0.4.7 by Martin Pool
Start making provision to test using a mock xmlrpc transport.
293
0.4.23 by Martin Pool
(register-branch) fix ordering of parameters and restore transport-level test.
294
    def __init__(self, branch_url,
0.4.15 by Martin Pool
(register-branch) Add command-line options
295
                 branch_name='',
296
                 branch_title='',
297
                 branch_description='',
0.4.23 by Martin Pool
(register-branch) fix ordering of parameters and restore transport-level test.
298
                 author_email='',
0.4.15 by Martin Pool
(register-branch) Add command-line options
299
                 product_name='',
300
                 ):
3246.4.3 by Daniel Watkins
Replaced another assert.
301
        if not branch_url:
302
            raise errors.InvalidURL(branch_url, "You need to specify a non-empty branch URL.")
0.4.4 by Martin Pool
Start forming xmlrpc requests
303
        self.branch_url = branch_url
0.4.15 by Martin Pool
(register-branch) Add command-line options
304
        if branch_name:
305
            self.branch_name = branch_name
0.4.14 by Martin Pool
Update xmlrpc api
306
        else:
0.4.15 by Martin Pool
(register-branch) Add command-line options
307
            self.branch_name = self._find_default_branch_name(self.branch_url)
308
        self.branch_title = branch_title
309
        self.branch_description = branch_description
310
        self.author_email = author_email
311
        self.product_name = product_name
0.4.4 by Martin Pool
Start forming xmlrpc requests
312
313
    def _request_params(self):
314
        """Return xmlrpc request parameters"""
0.4.6 by Martin Pool
Put the rest of the parameters into the registration request.
315
        # This must match the parameter tuple expected by Launchpad for this
316
        # method
0.4.4 by Martin Pool
Start forming xmlrpc requests
317
        return (self.branch_url,
0.4.15 by Martin Pool
(register-branch) Add command-line options
318
                self.branch_name,
0.4.14 by Martin Pool
Update xmlrpc api
319
                self.branch_title,
0.4.6 by Martin Pool
Put the rest of the parameters into the registration request.
320
                self.branch_description,
0.4.14 by Martin Pool
Update xmlrpc api
321
                self.author_email,
0.4.13 by Martin Pool
Update xmlrpc api to pass product name as a parameter.
322
                self.product_name,
0.4.4 by Martin Pool
Start forming xmlrpc requests
323
               )
324
0.4.15 by Martin Pool
(register-branch) Add command-line options
325
    def _find_default_branch_name(self, branch_url):
0.4.14 by Martin Pool
Update xmlrpc api
326
        i = branch_url.rfind('/')
327
        return branch_url[i+1:]
328
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
329
330
class BranchBugLinkRequest(BaseRequest):
331
    """Request to link a bzr branch in Launchpad to a bug."""
332
333
    _methodname = 'link_branch_to_bug'
334
335
    def __init__(self, branch_url, bug_id):
0.4.26 by Martin Pool
(register-branch) Add test for link_branch_to_bug and fix its parameters
336
        self.bug_id = bug_id
0.4.19 by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest.
337
        self.branch_url = branch_url
338
339
    def _request_params(self):
340
        """Return xmlrpc request parameters"""
341
        # This must match the parameter tuple expected by Launchpad for this
342
        # method
343
        return (self.branch_url, self.bug_id, '')
2898.4.2 by James Henstridge
Add ResolveLaunchpadURLRequest() class to handle lp: URL resolution.
344
345
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
346
class ResolveLaunchpadPathRequest(BaseRequest):
347
    """Request to resolve the path component of an lp: URL."""
2898.4.2 by James Henstridge
Add ResolveLaunchpadURLRequest() class to handle lp: URL resolution.
348
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
349
    _methodname = 'resolve_lp_path'
2898.4.2 by James Henstridge
Add ResolveLaunchpadURLRequest() class to handle lp: URL resolution.
350
    _authenticated = False
351
352
    def __init__(self, path):
3246.4.1 by Daniel Watkins
Replaced problematic assertion with exception call.
353
        if not path:
354
            raise errors.InvalidURL(path=path,
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
355
                                    extra="You must specify a project.")
2898.4.2 by James Henstridge
Add ResolveLaunchpadURLRequest() class to handle lp: URL resolution.
356
        self.path = path
357
358
    def _request_params(self):
359
        """Return xmlrpc request parameters"""
360
        return (self.path,)