From 2e2376d85423472c26a3a915960657789369f46a Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Tue, 21 Dec 2010 18:57:29 +0100 Subject: [PATCH 1/2] ubuntutools/lp/lpapicache.py: The wrapper classes now use the root uri from the Launchpad object for checking the resource type during runtime (the root uri doesn't need to be known at import time anymore) --- ubuntutools/lp/lpapicache.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index e78185f..9de3474 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -28,7 +28,6 @@ import sys import launchpadlib.launchpad as launchpad from launchpadlib.errors import HTTPError -from launchpadlib.uris import lookup_service_root from lazr.restfulclient.resource import Entry import ubuntutools.lp.libsupport as libsupport @@ -64,7 +63,7 @@ class Launchpad(object): else: raise AlreadyLoggedInError('Already logged in to Launchpad.') - def login_anonymously(self): + def login_anonymously(self, service=service, api_version=api_version): '''Enforce an anonymous login.''' if '_Launchpad__lp' not in self.__dict__: self.__lp = launchpad.Launchpad.login_anonymously('ubuntu-dev-tools', @@ -101,7 +100,7 @@ class BaseWrapper(object): resource_type = None # it's a base class after all def __new__(cls, data): - if isinstance(data, basestring) and data.startswith('%s%s/' % (lookup_service_root(service), api_version)): + if isinstance(data, basestring) and data.startswith(str(Launchpad._root_uri)): # looks like a LP API URL # check if it's already cached cached = cls._cache.get(data) @@ -116,7 +115,8 @@ class BaseWrapper(object): pass if isinstance(data, Entry): - if data.resource_type_link in cls.resource_type: + (service_root, resource_type) = data.resource_type_link.split('#') + if service_root == str(Launchpad._root_uri) and resource_type in cls.resource_type: # check if it's already cached cached = cls._cache.get(data.self_link) if not cached: @@ -157,7 +157,7 @@ class Distribution(BaseWrapper): ''' Wrapper class around a LP distribution object. ''' - resource_type = lookup_service_root(service) + api_version + '/#distribution' + resource_type = 'distribution' def __init__(self, *args): # Don't share _series and _archives between different Distributions @@ -239,14 +239,14 @@ class DistroSeries(BaseWrapper): ''' Wrapper class around a LP distro series object. ''' - resource_type = lookup_service_root(service) + api_version + '/#distro_series' + resource_type = 'distro_series' class Archive(BaseWrapper): ''' Wrapper class around a LP archive object. ''' - resource_type = lookup_service_root(service) + api_version + '/#archive' + resource_type = 'archive' def __init__(self, *args): # Don't share _srcpkgs between different Archives @@ -307,7 +307,7 @@ class SourcePackagePublishingHistory(BaseWrapper): ''' Wrapper class around a LP source package object. ''' - resource_type = lookup_service_root(service) + api_version + '/#source_package_publishing_history' + resource_type = 'source_package_publishing_history' def __init__(self, *args): # Don't share _builds between different SourcePackagePublishingHistory objects @@ -408,8 +408,8 @@ class PersonTeam(BaseWrapper): __metaclass__ = MetaPersonTeam resource_type = ( - lookup_service_root(service) + api_version + '/#person', - lookup_service_root(service) + api_version + '/#team', + 'person', + 'team', ) def __init__(self, *args): @@ -491,7 +491,7 @@ class Build(BaseWrapper): ''' Wrapper class around a build object. ''' - resource_type = lookup_service_root(service) + api_version + '/#build' + resource_type = 'build' def __str__(self): return u'%s: %s' % (self.arch_tag, self.buildstate) @@ -513,4 +513,4 @@ class DistributionSourcePackage(BaseWrapper): ''' Caching class for distribution_source_package objects. ''' - resource_type = lookup_service_root(service) + api_version + '/#distribution_source_package' + resource_type = 'distribution_source_package' From 9bf33b330b663801c4f326a3a146e0c35d84a6f4 Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Tue, 21 Dec 2010 19:16:09 +0100 Subject: [PATCH 2/2] Forgot to add changelog entry to close the bug. --- debian/changelog | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 8e754d7..08f8689 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low + [ Stefano Rivera ] * Convert debian/copyright to DEP5, make sure all scripts are listed (LP: #692003) * Drop preinst (pbuilder-dist bash_completion handling), it is not required @@ -17,7 +18,11 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low * ubuntutools/common.py: Remove https_proxy unsetting code, working around LP: #94130. - -- Stefano Rivera Mon, 20 Dec 2010 20:54:14 +0200 + [ Michael Bienia ] + * ubuntutools/lp/lpapicache.py: Allow easier selection of 'staging' as LP + instance to use (lp: #693060). + + -- Michael Bienia Tue, 21 Dec 2010 19:14:57 +0100 ubuntu-dev-tools (0.108) experimental; urgency=low