← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/add-new-processor-api into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/add-new-processor-api into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1225856 in Launchpad itself: "ProcessorFamily mostly just duplicates Processor"
  https://bugs.launchpad.net/launchpad/+bug/1225856

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/add-new-processor-api/+merge/185697

In preparation for removing ProcessorFamily, we need to wean IArchive off of it, but there are a few methods and properties exported over the API that use processor families directly. Add new APIs to IArchive that use processors so that scripts can be changed now before the processor family APIs get removed.
-- 
https://code.launchpad.net/~stevenk/launchpad/add-new-processor-api/+merge/185697
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/add-new-processor-api into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py	2013-08-19 06:43:04 +0000
+++ lib/lp/_schema_circular_imports.py	2013-09-16 04:43:50 +0000
@@ -200,7 +200,10 @@
     IPackageset,
     IPackagesetSet,
     )
-from lp.soyuz.interfaces.processor import IProcessorFamily
+from lp.soyuz.interfaces.processor import (
+    IProcessorFamily,
+    IProcessor,
+    )
 from lp.soyuz.interfaces.publishing import (
     IBinaryPackagePublishingHistory,
     IBinaryPackagePublishingHistoryEdit,
@@ -393,6 +396,8 @@
 patch_collection_property(IArchive, 'dependencies', IArchiveDependency)
 patch_collection_property(
     IArchive, 'enabled_restricted_families', IProcessorFamily)
+patch_collection_property(
+    IArchive, 'enabled_restricted_processors', IProcessor)
 patch_collection_return_type(IArchive, 'getAllPermissions', IArchivePermission)
 patch_collection_return_type(
     IArchive, 'getPermissionsForPerson', IArchivePermission)
@@ -492,7 +497,11 @@
     IArchive, '_addArchiveDependency', IArchiveDependency)
 patch_plain_parameter_type(
     IArchive, 'enableRestrictedFamily', 'family', IProcessorFamily)
+patch_plain_parameter_type(
+    IArchive, 'enableRestrictedProcessor', 'processor', IProcessor)
 
+# IProcessor
+patch_reference_property(IProcessor, 'family', IProcessorFamily)
 
 # IBuildFarmJob
 IBuildFarmJob['status'].vocabulary = BuildStatus

=== modified file 'lib/lp/soyuz/browser/tests/test_archive_webservice.py'
--- lib/lp/soyuz/browser/tests/test_archive_webservice.py	2013-08-14 06:40:07 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_webservice.py	2013-09-16 04:43:50 +0000
@@ -250,6 +250,7 @@
         transaction.commit()
         ws_archive = self.wsObject(archive, user=commercial_admin)
         self.assertContentEqual([], ws_archive.enabled_restricted_families)
+        self.assertContentEqual([], ws_archive.enabled_restricted_processors)
 
     def test_getByName(self):
         """The getByName method returns a processor family."""
@@ -291,6 +292,21 @@
         self.assertContentEqual(
             [ws_arm], ws_archive.enabled_restricted_families)
 
+    def test_enableRestrictedProcessor(self):
+        self.ws_version = 'devel'
+        archive = self.factory.makeArchive()
+        commercial = getUtility(ILaunchpadCelebrities).commercial_admin
+        commercial_admin = self.factory.makePerson(member_of=[commercial])
+        arm = getUtility(IProcessorFamilySet).getByName('arm')
+        arm.addProcessor('new-arm', 'New ARM Title', 'New ARM Description')
+        transaction.commit()
+        ws_arm = self.service.processors.getByName(name='new-arm')
+        ws_archive = self.wsObject(archive, user=commercial_admin)
+        self.assertContentEqual([], ws_archive.enabled_restricted_processors)
+        ws_archive.enableRestrictedProcessor(processor=ws_arm)
+        self.assertContentEqual(
+            [ws_arm], ws_archive.enabled_restricted_processors)
+
     def test_enableRestrictedFamily_owner(self):
         """A new family can be added to the enabled restricted set.
 

=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py	2013-08-28 16:18:35 +0000
+++ lib/lp/soyuz/interfaces/archive.py	2013-09-16 04:43:50 +0000
@@ -601,6 +601,17 @@
             readonly=True),
         as_of='devel')
 
+    enabled_restricted_processors = exported(
+        CollectionField(
+            title=_("Enabled restricted processors"),
+            description=_(
+                "The restricted architectures on which the archive "
+                "can build."),
+            value_type=Reference(schema=Interface),
+            # Really IProcessor.
+            readonly=True),
+        as_of='devel')
+
     def getSourcesForDeletion(name=None, status=None, distroseries=None):
         """All `ISourcePackagePublishingHistory` available for deletion.
 
@@ -1973,6 +1984,18 @@
         :param family: is an `IProcessorFamily` object.
         """
 
+    @operation_parameters(
+        processor=Reference(schema=Interface, required=True),
+        # Really IProcessor.
+    )
+    @export_write_operation()
+    @operation_for_version('devel')
+    def enableRestrictedProcessor(processor):
+        """Add the processor to the set of enabled restricted processors.
+
+        :param processor: is an `IProcessor` object.
+        """
+
 
 class IArchiveRestricted(Interface):
     """A writeable interface for restricted attributes of archives."""

=== modified file 'lib/lp/soyuz/interfaces/webservice.py'
--- lib/lp/soyuz/interfaces/webservice.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/interfaces/webservice.py	2013-09-16 04:43:50 +0000
@@ -54,11 +54,6 @@
 # XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
 # import bugs.  Break this up into a per-package thing.
 from lp import _schema_circular_imports
-from lp.services.webservice.apihelpers import (
-    patch_collection_property,
-    patch_plain_parameter_type,
-    patch_reference_property,
-    )
 from lp.soyuz.interfaces.archive import (
     AlreadySubscribed,
     ArchiveDisabled,
@@ -113,12 +108,3 @@
 
 
 _schema_circular_imports
-
-# IProcessor
-patch_reference_property(
-    IProcessor, 'family', IProcessorFamily)
-
-patch_collection_property(
-    IArchive, 'enabled_restricted_families', IProcessorFamily)
-patch_plain_parameter_type(
-    IArchive, 'enableRestrictedFamily', 'family', IProcessorFamily)

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2013-08-01 14:16:15 +0000
+++ lib/lp/soyuz/model/archive.py	2013-09-16 04:43:50 +0000
@@ -1994,12 +1994,21 @@
     enabled_restricted_families = property(_getEnabledRestrictedFamilies,
                                            _setEnabledRestrictedFamilies)
 
+    @property
+    def enabled_restricted_processors(self):
+        return [
+            family.processors[0]
+            for family in self.enabled_restricted_families]
+
     def enableRestrictedFamily(self, family):
         """See `IArchive`."""
         restricted = set(self.enabled_restricted_families)
         restricted.add(family)
         self.enabled_restricted_families = restricted
 
+    def enableRestrictedProcessor(self, processor):
+        self.enableRestrictedFamily(processor.family)
+
     def getPockets(self):
         """See `IArchive`."""
         if self.is_ppa:

=== modified file 'lib/lp/soyuz/stories/webservice/xx-archive.txt'
--- lib/lp/soyuz/stories/webservice/xx-archive.txt	2013-05-10 05:30:11 +0000
+++ lib/lp/soyuz/stories/webservice/xx-archive.txt	2013-09-16 04:43:50 +0000
@@ -45,6 +45,7 @@
     displayname: u'PPA for Celso Providelo'
     distribution_link: u'http://.../ubuntu'
     enabled_restricted_families_collection_link: u'http://.../~cprov/+archive/ppa/enabled_restricted_families'
+    enabled_restricted_processors_collection_link: u'http://.../~cprov/+archive/ppa/enabled_restricted_processors'
     external_dependencies: None
     name: u'ppa'
     owner_link: u'http://.../~cprov'


Follow ups