launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #17078
[Merge] lp:~wgrant/launchpad/official_packages-model into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/official_packages-model into lp:launchpad with lp:~wgrant/launchpad/supports_mirrors-model as a prerequisite.
Commit message:
Introduce a new Distribution.official_packages flag to replace remaining callsites of the hardcoded Distribution.full_functionality. I(Base|Derivative)Distribution also met their demise.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/official_packages-model/+merge/225772
A number of features are gated on Distribution.full_functionality, which is hardcoded to only be true for Ubuntu. We need PPAs and official package functionality for the RTM distro, but not distribution mirrors, so let's split full_functionality up into a few flags that separately enable bits of functionality without hardcoding distro names.
Some permissions around series change when a distribution uses Launchpad to manage its packages, as we don't trust the drivers to not break the primary archive. These restrictions are today activated when full_functionality is true. This branch introduces Distribution.official_packages to replace full_functionality for these purposes. The new flag just delegates to the old one until the DB column exists.
IBaseDistribution and IDerivativeDistribution were also hardcoded based on whether the distribution's name was "ubuntu", and only used to make IDerivativeDistribution:+addseries require launchpad.Moderate rather than IDistribution:+addseries' launchpad.Admin. But launchpad.Moderate already makes that distinction itself, so those interfaces have died.
--
https://code.launchpad.net/~wgrant/launchpad/official_packages-model/+merge/225772
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/official_packages-model into lp:launchpad.
=== modified file 'lib/lp/registry/browser/configure.zcml'
--- lib/lp/registry/browser/configure.zcml 2014-02-26 03:05:44 +0000
+++ lib/lp/registry/browser/configure.zcml 2014-07-07 05:12:30 +0000
@@ -1866,13 +1866,6 @@
name="+addseries"
for="lp.registry.interfaces.distribution.IDistribution"
class="lp.registry.browser.distroseries.DistroSeriesAddView"
- permission="launchpad.Admin"
- template="../templates/distroseries-add.pt">
- </browser:page>
- <browser:page
- name="+addseries"
- for="lp.registry.interfaces.distribution.IDerivativeDistribution"
- class="lp.registry.browser.distroseries.DistroSeriesAddView"
permission="launchpad.Moderate"
template="../templates/distroseries-add.pt">
</browser:page>
@@ -1940,7 +1933,6 @@
template="../../app/templates/generic-edit.pt"/>
<browser:menus
classes="
- DerivativeDistributionOverviewMenu
DistributionBugsMenu
DistributionFacets
DistributionMirrorsNavigationMenu
=== modified file 'lib/lp/registry/browser/distribution.py'
--- lib/lp/registry/browser/distribution.py 2014-07-07 05:12:29 +0000
+++ lib/lp/registry/browser/distribution.py 2014-07-07 05:12:30 +0000
@@ -6,7 +6,6 @@
__metaclass__ = type
__all__ = [
- 'DerivativeDistributionOverviewMenu',
'DistributionAddView',
'DistributionArchiveMirrorsRSSView',
'DistributionArchiveMirrorsView',
@@ -92,7 +91,6 @@
PillarViewMixin,
)
from lp.registry.interfaces.distribution import (
- IDerivativeDistribution,
IDistribution,
IDistributionMirrorMenuMarker,
IDistributionSet,
@@ -405,7 +403,7 @@
text = 'Search packages'
return Link('+search', text, icon='search')
- @enabled_with_permission('launchpad.Admin')
+ @enabled_with_permission('launchpad.Moderate')
def addseries(self):
text = 'Add series'
return Link('+addseries', text, icon='add')
@@ -460,16 +458,6 @@
return Link('+configure-translations', text, summary, icon='edit')
-class DerivativeDistributionOverviewMenu(DistributionOverviewMenu):
-
- usedfor = IDerivativeDistribution
-
- @enabled_with_permission('launchpad.Moderate')
- def addseries(self):
- text = 'Add series'
- return Link('+addseries', text, icon='add')
-
-
class DistributionBugsMenu(PillarBugsMenu):
usedfor = IDistribution
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2014-02-26 04:41:31 +0000
+++ lib/lp/registry/browser/distroseries.py 2014-07-07 05:12:30 +0000
@@ -593,18 +593,19 @@
'status' field. See `createStatusField` method.
"""
LaunchpadEditFormView.setUpFields(self)
- self.is_derivative = (
- not self.context.distribution.full_functionality)
+ self.series_are_harmless = (
+ not self.context.distribution.official_packages)
self.has_admin = check_permission('launchpad.Admin', self.context)
- if self.has_admin or self.is_derivative:
- # The user is an admin or this is an IDerivativeDistribution.
+ if self.has_admin or self.series_are_harmless:
+ # The user is an admin or damage to the series can't break
+ # archives.
self.form_fields = (
self.form_fields + self.createStatusField())
@action("Change")
def change_action(self, action, data):
"""Update the context and redirects to its overviw page."""
- if self.has_admin or self.is_derivative:
+ if self.has_admin or self.series_are_harmless:
self.updateDateReleased(data.get('status'))
self.updateContextFromData(data)
self.request.response.addInfoNotification(
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2014-02-26 05:35:04 +0000
+++ lib/lp/registry/browser/productseries.py 2014-07-07 05:12:30 +0000
@@ -597,7 +597,7 @@
# Do not allow users to create links to unpublished Ubuntu packages.
if (sourcepackagename is not None
- and distroseries.distribution.full_functionality):
+ and distroseries.distribution.official_packages):
source_package = distroseries.getSourcePackage(sourcepackagename)
if source_package.currentrelease is None:
message = ("The source package is not published in %s." %
=== modified file 'lib/lp/registry/browser/tests/distroseries-views.txt'
--- lib/lp/registry/browser/tests/distroseries-views.txt 2013-04-11 02:12:09 +0000
+++ lib/lp/registry/browser/tests/distroseries-views.txt 2014-07-07 05:12:30 +0000
@@ -184,7 +184,7 @@
>>> youbuntu = factory.makeDistribution(name='youbuntu')
>>> yo_series = factory.makeDistroSeries(name='melon')
>>> yo_series.title = 'Melon'
- >>> youbuntu.full_functionality
+ >>> youbuntu.official_packages
False
>>> yo_driver = factory.makePerson(name='yo-driver')
@@ -256,8 +256,8 @@
Drivers can create distro series
--------------------------------
-Users who are appointed as drivers of a distribution can create a series.
-Most distributions are an `IDerivativeDistribution`.
+Users who are appointed as drivers of a distribution that doesn't use
+Launchpad for package management can create a series.
>>> ignored = login_person(yo_driver)
>>> view = create_view(youbuntu, name='+addseries')
@@ -276,10 +276,11 @@
>>> print yo_series.displayname
Island
-Ubuntu is an exception. It's drivers cannot create series because Ubuntu
-is an `IBaseDistribution`.
+But drivers of distributions that use Soyuz officially (eg. Ubuntu)
+cannot create series, as that could have serious consequences for the
+primary archive.
- >>> ubuntu.full_functionality
+ >>> ubuntu.official_packages
True
>>> ignored = login_person(ubuntu.owner.teamowner)
@@ -293,8 +294,8 @@
Drivers editing distro series
.............................
-The series driver (release manager) can edit a series if the series belongs
-to a `IDerivativeDistribution`.
+The series driver (release manager) can edit a series if the series
+doesn't manage its packages in Launchpad.
>>> print yo_series.driver.name
yo-driver
@@ -317,7 +318,7 @@
>>> print yo_series.displayname
Mountain
-Drivers of an `IBaseDistribution` such as Ubuntu cannot edit a series.
+Drivers of packages with packages such as Ubuntu cannot edit a series.
>>> ignored = login_person(ubuntu.owner.teamowner)
>>> hoary.driver = yo_driver
=== modified file 'lib/lp/registry/browser/tests/milestone-views.txt'
--- lib/lp/registry/browser/tests/milestone-views.txt 2012-09-18 19:41:02 +0000
+++ lib/lp/registry/browser/tests/milestone-views.txt 2014-07-07 05:12:30 +0000
@@ -578,7 +578,7 @@
Distroseries driver and milestones
----------------------------------
-The driver of a series that belongs to an `IDerivativeDistribution` is a
+The driver of a series that doesn't manage its packages in Ubuntu is a
release manager and can create milestones.
>>> distroseries = factory.makeDistroSeries(name='pumpkin')
@@ -603,7 +603,7 @@
>>> check_permission('launchpad.Edit', view)
True
-The driver of an `IBaseDistribution` such as Ubuntu cannot create a
+The driver of a series that does have packages cannot create a
milestone.
>>> ignored = login_person(ubuntu_distro.owner.teamowner)
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2014-04-24 06:45:51 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2014-07-07 05:12:30 +0000
@@ -2579,8 +2579,8 @@
layer = DatabaseFunctionalLayer
def test_edit_full_functionality_sets_datereleased(self):
- # Full functionality distributions (IE: Ubuntu) have datereleased
- # set when the +edit view is used.
+ # Distributions that use Launchpad for package management (eg.
+ # Ubuntu) have datereleased set when the +edit view is used.
ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
form = {
=== modified file 'lib/lp/registry/doc/distroseries.txt'
--- lib/lp/registry/doc/distroseries.txt 2013-09-13 06:20:49 +0000
+++ lib/lp/registry/doc/distroseries.txt 2014-07-07 05:12:30 +0000
@@ -769,15 +769,15 @@
---------------------
Users with launchpad.Driver permission may create DistroSeries. In the
-case of an `IDerivativeDistribution` A user who is a driver can create
-the series and he is automatically assigned to the series' driver role
-so that he can edit it.
+case of a distribution that doesn't use Soyuz officially, a user who is
+a driver can create the series and he is automatically assigned to the
+series' driver role so that he can edit it.
>>> youbuntu = factory.makeDistribution(name='youbuntu')
>>> yo_driver = factory.makePerson(name='yo-driver')
>>> youbuntu.driver = yo_driver
>>> ignored = login_person(yo_driver)
- >>> youbuntu.full_functionality
+ >>> youbuntu.official_packages
False
>>> yo_series = youbuntu.newSeries(
@@ -805,9 +805,9 @@
>>> print yo_series.driver
None
-Ubuntu is an `IBaseDistribution` which requires special preparation for
-Soyuz and Translations before a series can be created. Ubuntu driver can
-not create series.
+Ubuntu uses Launchpad for package managemtn, so it requires special
+preparation for Soyuz and Translations before a series can be created.
+Ubuntu driver can not create series.
>>> ignored = login_person(ubuntu.owner.activemembers[0])
>>> ubuntu.driver = yo_driver
=== modified file 'lib/lp/registry/interfaces/distribution.py'
--- lib/lp/registry/interfaces/distribution.py 2014-07-07 05:12:29 +0000
+++ lib/lp/registry/interfaces/distribution.py 2014-07-07 05:12:30 +0000
@@ -6,8 +6,6 @@
__metaclass__ = type
__all__ = [
- 'IBaseDistribution',
- 'IDerivativeDistribution',
'IDistribution',
'IDistributionDriverRestricted',
'IDistributionEditRestricted',
@@ -311,15 +309,13 @@
"in the context of the currentseries.")),
exported_as="current_series")
- full_functionality = Attribute(
- "Whether or not we enable the full functionality of Launchpad for "
- "this distribution. Currently only Ubuntu and some derivatives "
- "get the full functionality of LP")
-
supports_mirrors = Attribute(
"Whether we enable mirror management functionality for this "
"distribution")
+ official_packages = Attribute(
+ "Whether Launchpad manages this distribution's packages itself.")
+
translation_focus = Choice(
title=_("Translation focus"),
description=_(
@@ -658,14 +654,6 @@
export_as_webservice_entry(as_of="beta")
-class IBaseDistribution(IDistribution):
- """A Distribution that is the base for other Distributions."""
-
-
-class IDerivativeDistribution(IDistribution):
- """A Distribution that derives from another Distribution."""
-
-
class IDistributionSet(Interface):
"""Interface for DistrosSet"""
export_as_webservice_collection(IDistribution)
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2014-07-07 05:12:29 +0000
+++ lib/lp/registry/model/distribution.py 2014-07-07 05:12:30 +0000
@@ -94,8 +94,6 @@
from lp.registry.errors import NoSuchDistroSeries
from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.distribution import (
- IBaseDistribution,
- IDerivativeDistribution,
IDistribution,
IDistributionSet,
)
@@ -253,16 +251,6 @@
return "<%s '%s' (%s)>" % (
self.__class__.__name__, displayname, self.name)
- def _init(self, *args, **kw):
- """Initialize an `IBaseDistribution` or `IDerivativeDistribution`."""
- SQLBase._init(self, *args, **kw)
- # Add a marker interface to set permissions for this kind
- # of distribution.
- if self.name == 'ubuntu':
- alsoProvides(self, IBaseDistribution)
- else:
- alsoProvides(self, IDerivativeDistribution)
-
@property
def pillar(self):
"""See `IBugTarget`."""
@@ -541,15 +529,17 @@
@property
def full_functionality(self):
"""See `IDistribution`."""
- if IBaseDistribution.providedBy(self):
- return True
- return False
+ return self.name == u'ubuntu'
@property
def supports_mirrors(self):
return self.full_functionality
@property
+ def official_packages(self):
+ return self.full_functionality
+
+ @property
def drivers(self):
"""See `IDistribution`."""
if self.driver is not None:
=== modified file 'lib/lp/registry/model/productseries.py'
--- lib/lp/registry/model/productseries.py 2013-08-19 06:43:04 +0000
+++ lib/lp/registry/model/productseries.py 2014-07-07 05:12:30 +0000
@@ -395,7 +395,7 @@
def setPackaging(self, distroseries, sourcepackagename, owner):
"""See IProductSeries."""
- if distroseries.distribution.full_functionality:
+ if distroseries.distribution.official_packages:
source_package = distroseries.getSourcePackage(sourcepackagename)
if source_package.currentrelease is None:
raise AssertionError(
=== modified file 'lib/lp/registry/templates/distribution-index.pt'
--- lib/lp/registry/templates/distribution-index.pt 2012-07-30 12:11:31 +0000
+++ lib/lp/registry/templates/distribution-index.pt 2014-07-07 05:12:30 +0000
@@ -41,7 +41,7 @@
class="description"
tal:content="structure context/description/fmt:text-to-html"/>
- <tal:search-packages condition="context/full_functionality">
+ <tal:search-packages condition="context/official_packages">
<h2>Packages</h2>
<form name="search" action="+search" method="get">
=== modified file 'lib/lp/security.py'
--- lib/lp/security.py 2014-06-20 12:30:39 +0000
+++ lib/lp/security.py 2014-07-07 05:12:30 +0000
@@ -1119,16 +1119,18 @@
class ModerateDistributionByDriversOrOwnersOrAdmins(AuthorizationBase):
"""Distribution drivers, owners, and admins may plan releases.
- Drivers of `IDerivativeDistribution`s can create series. Owners and
- admins can create series for all `IDistribution`s.
+ Drivers of distributions that don't manage their packages in
+ Launchpad can create series. Owners and admins can create series for
+ all `IDistribution`s.
"""
permission = 'launchpad.Moderate'
usedfor = IDistribution
def checkAuthenticated(self, user):
- if user.isDriver(self.obj) and not self.obj.full_functionality:
- # Drivers of derivative distributions can create a series that
- # they will be the release manager for.
+ if user.isDriver(self.obj) and not self.obj.official_packages:
+ # Damage to series with packages managed in Launchpad can
+ # cause serious strife. Restrict changes to the distro
+ # owner.
return True
return user.isOwner(self.obj) or user.in_admin
@@ -1219,9 +1221,10 @@
def checkAuthenticated(self, user):
if (user.inTeam(self.obj.driver)
- and not self.obj.distribution.full_functionality):
- # The series driver (release manager) may edit a series if the
- # distribution is an `IDerivativeDistribution`
+ and not self.obj.distribution.official_packages):
+ # Damage to series with packages managed in Launchpad can
+ # cause serious strife. Restrict changes to the distro
+ # owner.
return True
return (user.inTeam(self.obj.distribution.owner) or
user.in_admin)
=== modified file 'lib/lp/translations/model/translationpackagingjob.py'
--- lib/lp/translations/model/translationpackagingjob.py 2013-07-04 08:32:03 +0000
+++ lib/lp/translations/model/translationpackagingjob.py 2014-07-07 05:12:30 +0000
@@ -94,7 +94,7 @@
def run(self):
"""See `IRunnableJob`."""
logger = logging.getLogger()
- if not self.distroseries.distribution.full_functionality:
+ if not self.distroseries.distribution.official_packages:
logger.info(
'Skipping merge for unsupported distroseries "%s".' %
self.distroseries.displayname)
Follow ups