~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/lp_registration.py

  • Committer: Ian Clatworthy
  • Date: 2007-12-17 02:44:40 UTC
  • mto: (3119.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3120.
  • Revision ID: ian.clatworthy@internode.on.net-20071217024440-gb6e5qds0ol0r6sz
Dump help topics into text files in doc/en/user-reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
export BZR_LP_XMLRPC_URL=http://xmlrpc.staging.launchpad.net/bazaar/
33
33
'''
34
34
 
35
 
class InvalidLaunchpadInstance(errors.BzrError):
36
 
 
37
 
    _fmt = "%(lp_instance)s is not a valid Launchpad instance."
38
 
 
39
 
    def __init__(self, lp_instance):
40
 
        errors.BzrError.__init__(self, lp_instance=lp_instance)
41
 
 
42
 
 
43
35
class LaunchpadService(object):
44
36
    """A service to talk to Launchpad via XMLRPC.
45
 
 
 
37
    
46
38
    See http://bazaar-vcs.org/Specs/LaunchpadRpc for the methods we can call.
47
39
    """
48
40
 
49
 
    # NB: these should always end in a slash to avoid xmlrpclib appending
 
41
    # NB: this should always end in a slash to avoid xmlrpclib appending
50
42
    # '/RPC2'
51
 
    # We use edge as the default because:
52
 
    # Beta users get redirected to it
53
 
    # All users can use it
54
 
    # There is a bug in the launchpad side where redirection causes an OOPS.
55
 
    LAUNCHPAD_INSTANCE = {
56
 
        'production': 'https://xmlrpc.launchpad.net/bazaar/',
57
 
        'edge': 'https://xmlrpc.edge.launchpad.net/bazaar/',
58
 
        'staging': 'https://xmlrpc.staging.launchpad.net/bazaar/',
59
 
        'demo': 'https://xmlrpc.demo.launchpad.net/bazaar/',
60
 
        'dev': 'http://xmlrpc.launchpad.dev/bazaar/',
61
 
        }
62
 
    DEFAULT_SERVICE_URL = LAUNCHPAD_INSTANCE['edge']
 
43
    DEFAULT_SERVICE_URL = 'https://xmlrpc.launchpad.net/bazaar/'
63
44
 
64
45
    transport = None
65
46
    registrant_email = None
66
47
    registrant_password = None
67
48
 
68
49
 
69
 
    def __init__(self, transport=None, lp_instance=None):
 
50
    def __init__(self, transport=None):
70
51
        """Construct a new service talking to the launchpad rpc server"""
71
 
        self._lp_instance = lp_instance
72
52
        if transport is None:
73
53
            uri_type = urllib.splittype(self.service_url)[0]
74
54
            if uri_type == 'https':
89
69
        key = 'BZR_LP_XMLRPC_URL'
90
70
        if key in os.environ:
91
71
            return os.environ[key]
92
 
        elif self._lp_instance is not None:
93
 
            try:
94
 
                return self.LAUNCHPAD_INSTANCE[self._lp_instance]
95
 
            except KeyError:
96
 
                raise InvalidLaunchpadInstance(self._lp_instance)
97
72
        else:
98
73
            return self.DEFAULT_SERVICE_URL
99
74
 
205
180
                 author_email='',
206
181
                 product_name='',
207
182
                 ):
208
 
        assert branch_url, 'branch_url %r is invalid' % branch_url
 
183
        assert branch_url
209
184
        self.branch_url = branch_url
210
185
        if branch_name:
211
186
            self.branch_name = branch_name