launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #17061
[Merge] lp:~wgrant/launchpad/getPPAByName-cross-distro into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/getPPAByName-cross-distro into lp:launchpad with lp:~wgrant/launchpad/getPPAOwnedByPerson-cross-distro as a prerequisite.
Commit message:
Person.getPPAByName now supports a distribution argument. It still defaults to Ubuntu in order to not break existing API users.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/getPPAByName-cross-distro/+merge/225599
Person.getPPAByName now supports a distribution argument. It still defaults to Ubuntu in order to not break existing API users.
--
https://code.launchpad.net/~wgrant/launchpad/getPPAByName-cross-distro/+merge/225599
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/getPPAByName-cross-distro into lp:launchpad.
=== modified file 'cronscripts/parse-ppa-apache-access-logs.py'
--- cronscripts/parse-ppa-apache-access-logs.py 2012-01-01 03:14:54 +0000
+++ cronscripts/parse-ppa-apache-access-logs.py 2014-07-04 05:37:37 +0000
@@ -13,6 +13,7 @@
from zope.component import getUtility
+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.registry.interfaces.person import IPersonSet
from lp.services.apachelogparser.script import ParseApacheLogs
from lp.services.config import config
@@ -49,7 +50,8 @@
if person is None:
return
try:
- archive = person.getPPAByName(file_id[1])
+ archive = person.getPPAByName(
+ getUtility(ILaunchpadCelebrities).ubuntu, file_id[1])
except NoSuchPPA:
return None
# file_id[2] (distro) isn't used yet, since getPPAByName
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2014-04-30 12:59:44 +0000
+++ database/schema/security.cfg 2014-07-04 05:37:37 +0000
@@ -1005,6 +1005,7 @@
public.binarypackagerelease = SELECT
public.binarypackagereleasedownloadcount = SELECT, INSERT, UPDATE
public.country = SELECT
+public.distribution = SELECT
public.libraryfilealias = SELECT
public.parsedapachelog = SELECT, INSERT, UPDATE
public.person = SELECT
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py 2014-06-20 06:28:04 +0000
+++ lib/lp/_schema_circular_imports.py 2014-07-04 05:37:37 +0000
@@ -322,6 +322,8 @@
patch_reference_property(IPersonViewRestricted, 'archive', IArchive)
patch_collection_property(IPersonViewRestricted, 'ppas', IArchive)
+patch_plain_parameter_type(
+ IPersonLimitedView, 'getPPAByName', 'distribution', IDistribution)
patch_entry_return_type(IPersonLimitedView, 'getPPAByName', IArchive)
patch_entry_return_type(IPersonEditRestricted, 'createPPA', IArchive)
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2014-06-11 08:29:40 +0000
+++ lib/lp/archivepublisher/publishing.py 2014-07-04 05:37:37 +0000
@@ -884,6 +884,7 @@
for pub in self.archive.getAllPublishedBinaries(include_removed=False):
pub.dateremoved = UTC_NOW
+ # XXX wgrant 2014-07-03: Needs checking for multi-distro sanity.
for directory in (root_dir, self._config.metaroot):
if not os.path.exists(directory):
continue
@@ -905,7 +906,8 @@
count = 1
while True:
try:
- self.archive.owner.getPPAByName(new_name)
+ self.archive.owner.getPPAByName(
+ self.archive.distribution, new_name)
except NoSuchPPA:
break
new_name = '%s%d' % (base_name, count)
=== modified file 'lib/lp/archiveuploader/tests/upload-path-parsing.txt'
--- lib/lp/archiveuploader/tests/upload-path-parsing.txt 2010-08-23 16:51:11 +0000
+++ lib/lp/archiveuploader/tests/upload-path-parsing.txt 2014-07-04 05:37:37 +0000
@@ -138,10 +138,12 @@
an error.
>>> from zope.component import getUtility
+ >>> from lp.registry.interfaces.distribution import IDistributionSet
>>> from lp.registry.interfaces.person import IPersonSet
>>> cprov = getUtility(IPersonSet).getByName('cprov')
- >>> cprov_ppa = cprov.getPPAByName('ppa')
+ >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
+ >>> cprov_ppa = cprov.getPPAByName(ubuntu, 'ppa')
>>> cprov_ppa.disable()
>>> import transaction
@@ -229,7 +231,6 @@
So, here is a binary upload path to the primary archive:
- >>> from lp.registry.interfaces.distribution import IDistributionSet
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
>>> primary = getUtility(IArchiveSet).getByDistroPurpose(
... ubuntu, ArchivePurpose.PRIMARY, 'primary')
=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
--- lib/lp/archiveuploader/uploadprocessor.py 2014-04-29 17:26:25 +0000
+++ lib/lp/archiveuploader/uploadprocessor.py 2014-07-04 05:37:37 +0000
@@ -57,6 +57,7 @@
from zope.component import getUtility
from lp.app.errors import NotFoundError
+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.archiveuploader.livefsupload import LiveFSUpload
from lp.archiveuploader.nascentupload import (
EarlyReturnUploadError,
@@ -830,7 +831,8 @@
distribution_and_suite = parts[2:]
try:
- archive = person.getPPAByName(ppa_name)
+ archive = person.getPPAByName(
+ getUtility(ILaunchpadCelebrities).ubuntu, ppa_name)
except NoSuchPPA:
raise PPAUploadPathError(
"Could not find a PPA named '%s' for '%s'."
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2014-02-19 02:11:16 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2014-07-04 05:37:37 +0000
@@ -664,7 +664,7 @@
self.assertTrue(browser.url.endswith('/~eric/+recipe/name'))
# Since no PPA name was entered, the default name (ppa) was used.
login(ANONYMOUS)
- new_ppa = self.user.getPPAByName('ppa')
+ new_ppa = self.user.getPPAByName(self.ppa.distribution, 'ppa')
self.assertIsNot(None, new_ppa)
def test_create_new_ppa_duplicate(self):
@@ -732,7 +732,7 @@
self.assertTrue(browser.url.endswith('/~vikings/+recipe/name'))
# Since no PPA name was entered, the default name (ppa) was used.
login(ANONYMOUS)
- new_ppa = team.getPPAByName('ppa')
+ new_ppa = team.getPPAByName(self.ppa.distribution, 'ppa')
self.assertIsNot(None, new_ppa)
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2014-05-06 11:51:34 +0000
+++ lib/lp/registry/interfaces/person.py 2014-07-04 05:37:37 +0000
@@ -664,11 +664,12 @@
Bool(title=_("Is this a probationary user?"), readonly=True))
@operation_parameters(
+ distribution=Reference(schema=Interface, required=False),
name=TextLine(required=True, constraint=name_validator))
@operation_returns_entry(Interface) # Really IArchive.
@export_read_operation()
@operation_for_version("beta")
- def getPPAByName(name):
+ def getPPAByName(distribution, name):
"""Return a PPA with the given name if it exists.
:param name: A string with the exact name of the ppa being looked up.
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2014-07-04 05:37:37 +0000
+++ lib/lp/registry/model/person.py 2014-07-04 05:37:37 +0000
@@ -3061,11 +3061,13 @@
(ArchiveStatus.ACTIVE, ArchiveStatus.DELETING)),
filter).order_by(Archive.name)
- def getPPAByName(self, name):
+ def getPPAByName(self, distribution=None, name=None):
"""See `IPerson`."""
+ assert name is not None
+ if distribution is None:
+ distribution = getUtility(ILaunchpadCelebrities).ubuntu
ppa = getUtility(IArchiveSet).getPPAOwnedByPerson(
- self, distribution=getUtility(ILaunchpadCelebrities).ubuntu,
- name=name)
+ self, distribution=distribution, name=name)
if ppa is None:
raise NoSuchPPA(name)
return ppa
=== modified file 'lib/lp/registry/stories/webservice/xx-person.txt'
--- lib/lp/registry/stories/webservice/xx-person.txt 2014-05-19 11:33:05 +0000
+++ lib/lp/registry/stories/webservice/xx-person.txt 2014-07-04 05:37:37 +0000
@@ -619,6 +619,13 @@
>>> print webservice.named_get(
... mark['self_link'], 'getPPAByName',
+ ... distribution='/ubuntu', name='ppa').jsonBody()['self_link']
+ http://.../~mark/+archive/ppa
+
+If no distribution is specified, it defaults to Ubuntu.
+
+ >>> print webservice.named_get(
+ ... mark['self_link'], 'getPPAByName',
... name='ppa').jsonBody()['self_link']
http://.../~mark/+archive/ppa
@@ -626,17 +633,19 @@
returned.
>>> print webservice.named_get(
- ... mark['self_link'], 'getPPAByName', name='boing')
+ ... mark['self_link'], 'getPPAByName', distribution='/debian',
+ ... name='ppa')
HTTP/1.1 404 Not Found
...
- No such ppa: 'boing'.
+ No such ppa: 'ppa'.
The method doesn't even bother to execute the lookup if the given
'name' doesn't match the constraints for PPA names. An error message
indicating what was wrong is returned.
>>> print webservice.named_get(
- ... mark['self_link'], 'getPPAByName', name='XpTo@#$%')
+ ... mark['self_link'], 'getPPAByName', distribution='/ubuntu',
+ ... name='XpTo@#$%')
HTTP/1.1 400 Bad Request
...
name:
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2014-06-30 13:51:15 +0000
+++ lib/lp/soyuz/browser/archive.py 2014-07-04 05:37:37 +0000
@@ -184,7 +184,8 @@
"""
person = getUtility(IPersonSet).getByName(person_name)
try:
- archive = person.getPPAByName(ppa_name)
+ archive = person.getPPAByName(
+ getUtility(ILaunchpadCelebrities).ubuntu, ppa_name)
except NoSuchPPA:
raise NotFoundError("%s/%s", (person_name, ppa_name))
=== modified file 'lib/lp/soyuz/browser/tests/test_publishing.py'
--- lib/lp/soyuz/browser/tests/test_publishing.py 2013-11-28 08:51:32 +0000
+++ lib/lp/soyuz/browser/tests/test_publishing.py 2014-07-04 05:37:37 +0000
@@ -15,6 +15,7 @@
from zope.publisher.interfaces import NotFound
from zope.security.interfaces import Unauthorized
+from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.person import IPersonSet
from lp.services.webapp.publisher import (
canonical_url,
@@ -46,7 +47,8 @@
# Create everything we need to create builds, such as a
# DistroArchSeries and a builder.
self.processor = self.factory.makeProcessor()
- self.distroseries = self.factory.makeDistroSeries()
+ self.distroseries = self.factory.makeDistroSeries(
+ distribution=getUtility(IDistributionSet)['ubuntu'])
self.das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor,
supports_virtualized=True)
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2014-07-04 05:37:37 +0000
+++ lib/lp/soyuz/model/archive.py 2014-07-04 05:37:37 +0000
@@ -2102,7 +2102,7 @@
if proposed_name is None:
proposed_name = 'ppa'
try:
- owner.getPPAByName(proposed_name)
+ owner.getPPAByName(ubuntu, proposed_name)
except NoSuchPPA:
return None
else:
@@ -2237,11 +2237,12 @@
(name, distribution.name))
else:
archive = Archive.selectOneBy(
- owner=owner, name=name, purpose=ArchivePurpose.PPA)
+ owner=owner, distribution=distribution, name=name,
+ purpose=ArchivePurpose.PPA)
if archive is not None:
raise AssertionError(
- "Person '%s' already has a PPA named '%s'." %
- (owner.name, name))
+ "Person '%s' already has a PPA for %s named '%s'." %
+ (owner.name, distribution.name, name))
# Signing-key for the default PPA is reused when it's already present.
signing_key = None
=== modified file 'lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt'
--- lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt 2013-09-27 04:13:23 +0000
+++ lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt 2014-07-04 05:37:37 +0000
@@ -254,9 +254,11 @@
>>> from zope.component import getUtility
>>> from lp.registry.interfaces.person import IPersonSet
+ >>> from lp.registry.interfaces.distribution import IDistributionSet
>>> login('admin@xxxxxxxxxxxxx')
>>> devs = getUtility(IPersonSet).getByName('landscape-developers')
- >>> archive = devs.getPPAByName('develppa')
+ >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
+ >>> archive = devs.getPPAByName(ubuntu, 'develppa')
>>> ignore = factory.makeSourcePackagePublishingHistory(archive=archive)
>>> logout()
@@ -673,7 +675,7 @@
>>> from lp.soyuz.enums import ArchiveStatus
>>> login('admin@xxxxxxxxxxxxx')
>>> cprov = getUtility(IPersonSet).getByName('cprov')
- >>> cprov.getPPAByName('edge').status = ArchiveStatus.DELETED
+ >>> cprov.getPPAByName(ubuntu, 'edge').status = ArchiveStatus.DELETED
>>> logout()
>>> cprov_browser.open("http://launchpad.dev/~cprov")
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2014-07-04 05:37:37 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2014-07-04 05:37:37 +0000
@@ -99,6 +99,7 @@
person_logged_in,
TestCaseWithFactory,
)
+from lp.testing._webservice import QueryCollector
from lp.testing.layers import (
DatabaseFunctionalLayer,
LaunchpadFunctionalLayer,
@@ -106,7 +107,6 @@
)
from lp.testing.matchers import HasQueryCount
from lp.testing.pages import webservice_for_person
-from lp.testing._webservice import QueryCollector
class TestGetPublicationsInArchive(TestCaseWithFactory):
@@ -2964,24 +2964,44 @@
def setUp(self):
super(TestPPALookup, self).setUp()
+ self.ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+ self.notbuntu = self.factory.makeDistribution()
self.person = self.factory.makePerson()
self.factory.makeArchive(owner=self.person, name="ppa")
self.nightly = self.factory.makeArchive(
owner=self.person, name="nightly")
+ self.other_ppa = self.factory.makeArchive(
+ owner=self.person, distribution=self.notbuntu, name="ppa")
+ self.third_ppa = self.factory.makeArchive(
+ owner=self.person, distribution=self.notbuntu, name="aap")
def test_ppas(self):
# IPerson.ppas returns all owned PPAs ordered by name.
self.assertEqual(
- ["nightly", "ppa"], [ppa.name for ppa in self.person.ppas])
+ ["aap", "nightly", "ppa", "ppa"],
+ [ppa.name for ppa in self.person.ppas])
def test_getPPAByName(self):
- default_ppa = self.person.getPPAByName("ppa")
+ default_ppa = self.person.getPPAByName(self.ubuntu, "ppa")
self.assertEqual(self.person.archive, default_ppa)
- nightly_ppa = self.person.getPPAByName("nightly")
+ nightly_ppa = self.person.getPPAByName(self.ubuntu, "nightly")
self.assertEqual(self.nightly, nightly_ppa)
+ other_ppa = self.person.getPPAByName(self.notbuntu, "ppa")
+ self.assertEqual(self.other_ppa, other_ppa)
+ third_ppa = self.person.getPPAByName(self.notbuntu, "aap")
+ self.assertEqual(self.third_ppa, third_ppa)
+
+ def test_getPPAByName_defaults_to_ubuntu(self):
+ default_ppa = self.person.getPPAByName(None, "ppa")
+ self.assertEqual(self.person.archive, default_ppa)
def test_NoSuchPPA(self):
- self.assertRaises(NoSuchPPA, self.person.getPPAByName, "not-found")
+ self.assertRaises(
+ NoSuchPPA, self.person.getPPAByName, self.ubuntu, "not-found")
+
+ def test_NoSuchPPA_default_distro(self):
+ self.assertRaises(
+ NoSuchPPA, self.person.getPPAByName, None, "aap")
class TestDisplayName(TestCaseWithFactory):
=== modified file 'lib/lp/soyuz/tests/test_livefs.py'
--- lib/lp/soyuz/tests/test_livefs.py 2014-07-01 02:01:54 +0000
+++ lib/lp/soyuz/tests/test_livefs.py 2014-07-04 05:37:37 +0000
@@ -26,6 +26,7 @@
from lp.buildmaster.interfaces.buildqueue import IBuildQueue
from lp.buildmaster.model.buildqueue import BuildQueue
from lp.registry.enums import PersonVisibility
+from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.database.constants import UTC_NOW
from lp.services.features.testing import FeatureFixture
@@ -532,7 +533,9 @@
def test_requestBuild_archive_disabled(self):
# Build requests against a disabled archive are rejected.
- distroseries = self.factory.makeDistroSeries(registrant=self.person)
+ distroseries = self.factory.makeDistroSeries(
+ distribution=getUtility(IDistributionSet)['ubuntu'],
+ registrant=self.person)
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries, owner=self.person)
distroarchseries_url = api_url(distroarchseries)
@@ -550,7 +553,9 @@
def test_requestBuild_archive_private_owners_match(self):
# Build requests against a private archive are allowed if the LiveFS
# and Archive owners match exactly.
- distroseries = self.factory.makeDistroSeries(registrant=self.person)
+ distroseries = self.factory.makeDistroSeries(
+ distribution=getUtility(IDistributionSet)['ubuntu'],
+ registrant=self.person)
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries, owner=self.person)
distroarchseries_url = api_url(distroarchseries)
@@ -567,7 +572,9 @@
def test_requestBuild_archive_private_owners_mismatch(self):
# Build requests against a private archive are rejected if the
# LiveFS and Archive owners do not match exactly.
- distroseries = self.factory.makeDistroSeries(registrant=self.person)
+ distroseries = self.factory.makeDistroSeries(
+ distribution=getUtility(IDistributionSet)['ubuntu'],
+ registrant=self.person)
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries, owner=self.person)
distroarchseries_url = api_url(distroarchseries)
@@ -587,7 +594,9 @@
def test_getBuilds(self):
# The builds, completed_builds, and pending_builds properties are as
# expected.
- distroseries = self.factory.makeDistroSeries(registrant=self.person)
+ distroseries = self.factory.makeDistroSeries(
+ distribution=getUtility(IDistributionSet)['ubuntu'],
+ registrant=self.person)
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries, owner=self.person)
distroarchseries_url = api_url(distroarchseries)
Follow ups