ubuntutools/lp/lpapicache.py:

Re-add dropped "beta/" to the resource type URLs
 Use lookup_service_root() when checking for LP API URLs
This commit is contained in:
Michael Bienia 2010-02-20 15:18:52 +01:00
parent 4da9387f3d
commit caafd18fb9

View File

@ -79,7 +79,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('https://api.edge.launchpad.net/beta/'):
if isinstance(data, basestring) and data.startswith(lookup_service_root(service) + 'beta/'):
# looks like a LP API URL
# check if it's already cached
cached = cls._cache.get(data)
@ -134,7 +134,7 @@ class Distribution(BaseWrapper):
'''
Wrapper class around a LP distribution object.
'''
resource_type = lookup_service_root(service) + '#distribution'
resource_type = lookup_service_root(service) + 'beta/#distribution'
def __init__(self, *args):
# Don't share _series and _archives between different Distributions
@ -216,14 +216,14 @@ class DistroSeries(BaseWrapper):
'''
Wrapper class around a LP distro series object.
'''
resource_type = lookup_service_root(service) + '#distro_series'
resource_type = lookup_service_root(service) + 'beta/#distro_series'
class Archive(BaseWrapper):
'''
Wrapper class around a LP archive object.
'''
resource_type = lookup_service_root(service) + '#archive'
resource_type = lookup_service_root(service) + 'beta/#archive'
def __init__(self, *args):
# Don't share _srcpkgs between different Archives
@ -284,7 +284,7 @@ class SourcePackagePublishingHistory(BaseWrapper):
'''
Wrapper class around a LP source package object.
'''
resource_type = lookup_service_root(service) + '#source_package_publishing_history'
resource_type = lookup_service_root(service) + 'beta/#source_package_publishing_history'
def __init__(self, *args):
# Don't share _builds between different SourcePackagePublishingHistory objects
@ -365,7 +365,10 @@ class PersonTeam(BaseWrapper):
'''
Wrapper class around a LP person or team object.
'''
resource_type = (lookup_service_root(service) + '#person', lookup_service_root(service) + '#team')
resource_type = (
lookup_service_root(service) + 'beta/#person',
lookup_service_root(service) + 'beta/#team',
)
_me = None # the PersonTeam object of the currently authenticated LP user
@ -468,7 +471,7 @@ class Build(BaseWrapper):
'''
Wrapper class around a build object.
'''
resource_type = lookup_service_root(service) + '#build'
resource_type = lookup_service_root(service) + 'beta/#build'
def __str__(self):
return u'%s: %s' % (self.arch_tag, self.buildstate)
@ -490,4 +493,4 @@ class DistributionSourcePackage(BaseWrapper):
'''
Caching class for distribution_source_package objects.
'''
resource_type = lookup_service_root(service) + '#distribution_source_package'
resource_type = lookup_service_root(service) + 'beta/#distribution_source_package'