Merge lp:~wgrant/launchpad/bug-558905-get-archive into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: 10927
Proposed branch: lp:~wgrant/launchpad/bug-558905-get-archive
Merge into: lp:launchpad
Diff against target: 149 lines (+45/-18)
7 files modified
lib/canonical/launchpad/interfaces/_schema_circular_imports.py (+2/-0)
lib/lp/registry/browser/distribution.py (+1/-2)
lib/lp/registry/doc/distribution.txt (+17/-0)
lib/lp/registry/interfaces/distribution.py (+12/-0)
lib/lp/registry/model/distribution.py (+5/-0)
lib/lp/registry/stories/webservice/xx-distribution.txt (+8/-0)
lib/lp/soyuz/browser/archive.py (+0/-16)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-558905-get-archive
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+25300@code.launchpad.net

Commit message

Create and expose Distribution.getArchive.

Description of the change

This branch fixes bug 558905, moving traverse_distro_archive to Distribution.getArchive and exposing it over the API. I've replaced the old function's single callsite with a call to the new method.

There is no lint.

To post a comment you must log in.
Revision history for this message
Eleanor Berger (intellectronica) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
2--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-04-23 03:16:22 +0000
3+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-05-14 08:12:30 +0000
4@@ -276,6 +276,8 @@
5 patch_reference_property(
6 IDistribution, 'currentseries', IDistroSeries)
7 patch_entry_return_type(
8+ IDistribution, 'getArchive', IArchive)
9+patch_entry_return_type(
10 IDistribution, 'getSeries', IDistroSeries)
11 patch_collection_return_type(
12 IDistribution, 'getDevelopmentSeries', IDistroSeries)
13
14=== modified file 'lib/lp/registry/browser/distribution.py'
15--- lib/lp/registry/browser/distribution.py 2010-03-08 05:03:15 +0000
16+++ lib/lp/registry/browser/distribution.py 2010-05-14 08:12:30 +0000
17@@ -51,7 +51,6 @@
18 from lp.registry.browser.announcement import HasAnnouncementsView
19 from lp.registry.browser.menu import (
20 IRegistryCollectionNavigationMenu, RegistryCollectionActionMenuBase)
21-from lp.soyuz.browser.archive import traverse_distro_archive
22 from lp.bugs.browser.bugtask import BugTargetTraversalMixin
23 from lp.answers.browser.faqtarget import FAQTargetNavigationMixin
24 from canonical.launchpad.browser.feeds import FeedsMixin
25@@ -161,7 +160,7 @@
26
27 @stepthrough('+archive')
28 def traverse_archive(self, name):
29- return traverse_distro_archive(self.context, name)
30+ return self.context.getArchive(name)
31
32
33 class DistributionSetNavigation(Navigation):
34
35=== modified file 'lib/lp/registry/doc/distribution.txt'
36--- lib/lp/registry/doc/distribution.txt 2010-03-23 14:52:14 +0000
37+++ lib/lp/registry/doc/distribution.txt 2010-05-14 08:12:30 +0000
38@@ -592,3 +592,20 @@
39 >>> [milestone.name for milestone in debian.all_milestones]
40 [u'3.1', u'3.1-rc1', u'woody-rc1']
41
42+
43+== Archives ==
44+
45+A distribution archive (primary, partner, debug or copy) can be retrieved
46+by name using IDistribution.getArchive.
47+
48+ >>> def display_archive(archive):
49+ ... print '%s %s %s' % (
50+ ... archive.distribution.name, archive.owner.name, archive.name)
51+ >>> display_archive(ubuntu.getArchive('primary'))
52+ ubuntu ubuntu-team primary
53+ >>> display_archive(ubuntu.getArchive('partner'))
54+ ubuntu ubuntu-team partner
55+ >>> display_archive(debian.getArchive('primary'))
56+ debian mark primary
57+ >>> ubuntu.getArchive('ppa')
58+ >>> debian.getArchive('partner')
59
60=== modified file 'lib/lp/registry/interfaces/distribution.py'
61--- lib/lp/registry/interfaces/distribution.py 2010-05-07 18:18:56 +0000
62+++ lib/lp/registry/interfaces/distribution.py 2010-05-14 08:12:30 +0000
63@@ -295,6 +295,18 @@
64 def __iter__():
65 """Iterate over the series for this distribution."""
66
67+ @operation_parameters(
68+ name=TextLine(title=_("Archive name"), required=True))
69+ @operation_returns_entry(Interface)
70+ @export_read_operation()
71+ def getArchive(name):
72+ """Return the distribution archive with the given name.
73+
74+ Only distribution archives are considered -- PPAs will not be found.
75+
76+ :param name: The name of the archive, e.g. 'partner'
77+ """
78+
79 # Really IDistroSeries, see _schema_circular_imports.py.
80 @operation_returns_collection_of(Interface)
81 @export_operation_as(name="getDevelopmentSeries")
82
83=== modified file 'lib/lp/registry/model/distribution.py'
84--- lib/lp/registry/model/distribution.py 2010-05-07 20:09:03 +0000
85+++ lib/lp/registry/model/distribution.py 2010-05-14 08:12:30 +0000
86@@ -516,6 +516,11 @@
87 def __iter__(self):
88 return iter(self.series)
89
90+ def getArchive(self, name):
91+ """See `IDistribution.`"""
92+ return getUtility(
93+ IArchiveSet).getByDistroAndName(self, name)
94+
95 def getSeries(self, name_or_version):
96 """See `IDistribution`."""
97 distroseries = DistroSeries.selectOneBy(
98
99=== modified file 'lib/lp/registry/stories/webservice/xx-distribution.txt'
100--- lib/lp/registry/stories/webservice/xx-distribution.txt 2010-04-30 17:45:51 +0000
101+++ lib/lp/registry/stories/webservice/xx-distribution.txt 2010-05-14 08:12:30 +0000
102@@ -118,6 +118,14 @@
103 http://.../ubuntu/+source/foobar
104 http://.../ubuntu/+source/commercialpackage
105
106+"getArchive" returns a distribution archive (not a PPA) with the given name.
107+
108+ >>> partner = webservice.named_get(
109+ ... ubuntu['self_link'], 'getArchive',
110+ ... name='partner').jsonBody()
111+ >>> print partner['self_link']
112+ http://.../ubuntu/+archive/partner
113+
114 "getMirrorByName" returns a mirror by its unique name.
115
116 >>> canonical_releases = webservice.named_get(
117
118=== modified file 'lib/lp/soyuz/browser/archive.py'
119--- lib/lp/soyuz/browser/archive.py 2010-04-30 03:10:17 +0000
120+++ lib/lp/soyuz/browser/archive.py 2010-05-14 08:12:30 +0000
121@@ -23,7 +23,6 @@
122 'ArchiveView',
123 'ArchiveViewBase',
124 'make_archive_vocabulary',
125- 'traverse_distro_archive',
126 'traverse_named_ppa',
127 ]
128
129@@ -111,21 +110,6 @@
130 return "This archive is private."
131
132
133-def traverse_distro_archive(distribution, name):
134- """For distribution archives, traverse to the right place.
135-
136- This traversal only applies to distribution archives, not PPAs.
137-
138- :param name: The name of the archive, e.g. 'partner'
139- """
140- archive = getUtility(
141- IArchiveSet).getByDistroAndName(distribution, name)
142- if archive is None:
143- raise NotFoundError(name)
144-
145- return archive
146-
147-
148 def traverse_named_ppa(person_name, ppa_name):
149 """For PPAs, traverse the right place.
150