launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02268
[Merge] lp:~wgrant/launchpad/goodbye-binarypackagereleaseset into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/goodbye-binarypackagereleaseset into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#5947 Missing tests for BinaryPackageReleaseSet
https://bugs.launchpad.net/bugs/5947
#693989 BinaryPackageReleaseSet is obsolete and should be removed
https://bugs.launchpad.net/bugs/693989
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/goodbye-binarypackagereleaseset/+merge/45094
BinaryPackageReleaseSet is nowadays largely vestigial, only serving a single callsite in ArchiveCruftChecker. This replaces that callsite with another more sensible method, and removes BinaryPackageReleaseSet along with some of its wrappers.
ArchiveCruftChecker is untested, but the change is simple, has been tested locally, and will soon be verified on dogfood.
--
https://code.launchpad.net/~wgrant/launchpad/goodbye-binarypackagereleaseset/+merge/45094
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/goodbye-binarypackagereleaseset into lp:launchpad.
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2010-11-09 14:35:44 +0000
+++ lib/lp/soyuz/configure.zcml 2011-01-04 02:49:57 +0000
@@ -83,22 +83,6 @@
interface="lp.soyuz.interfaces.binarypackagerelease.IBinaryPackageRelease"/>
</class>
- <!-- BinaryPackageReleaseSet -->
-
- <class
- class="lp.soyuz.model.binarypackagerelease.BinaryPackageReleaseSet">
- <allow
- interface="lp.soyuz.interfaces.binarypackagerelease.IBinaryPackageReleaseSet"/>
- <implements
- interface="zope.app.container.interfaces.IItemContainer"/>
- </class>
- <securedutility
- class="lp.soyuz.model.binarypackagerelease.BinaryPackageReleaseSet"
- provides="lp.soyuz.interfaces.binarypackagerelease.IBinaryPackageReleaseSet">
- <allow
- interface="lp.soyuz.interfaces.binarypackagerelease.IBinaryPackageReleaseSet"/>
- </securedutility>
-
<!-- SourcePackageRelease -->
<class
=== modified file 'lib/lp/soyuz/doc/binarypackagerelease.txt'
--- lib/lp/soyuz/doc/binarypackagerelease.txt 2010-11-06 12:08:24 +0000
+++ lib/lp/soyuz/doc/binarypackagerelease.txt 2011-01-04 02:49:57 +0000
@@ -6,7 +6,6 @@
>>> from canonical.launchpad.webapp.testing import verifyObject
>>> from lp.soyuz.interfaces.binarypackagerelease import (
... IBinaryPackageRelease,
- ... IBinaryPackageReleaseSet,
... )
>>> from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
@@ -135,79 +134,6 @@
>>> transaction.abort()
-BinaryPackageReleaseSet utility:
-
- >>> binset = getUtility(IBinaryPackageReleaseSet)
- >>> verifyObject(IBinaryPackageReleaseSet, binset)
- True
-
- >>> ret = binset.findByNameInDistroSeries(warty, 'cdr')
- >>> for item in ret:
- ... print item.name
- cdrkit
-
-Note that two pmounts are returned because they are published in
-different architectures:
-
- >>> ret = binset.getByNameInDistroSeries(hoary, 'pmount')
- >>> for item in ret:
- ... print item.name
- pmount
- pmount
-
- >>> result = binset.findByNameInDistroSeries(warty, 'moz')
- >>> print len(list(result))
- 5
- >>> result = binset.findByNameInDistroSeries(warty, 'nosuchpackage')
- >>> print len(list(result))
- 0
- >>> result = binset.findByNameInDistroSeries(
- ... warty, 'Web Browser', fti=True)
- >>> print len(list(result))
- 2
- >>> result = binset.findByNameInDistroSeries(
- ... warty, 'X50keBLvzk', fti=True)
- >>> print len(list(result))
- 0
- >>> result = binset.findByNameInDistroSeries(
- ... warty, 'moz', archtag="nosucharch")
- >>> print len(list(result))
- 0
-
-
-getByNameInDistroSeries
-------------------------
-
- >>> result = binset.getByNameInDistroSeries(warty)
- >>> print len(list(result))
- 9
- >>> result = binset.getByNameInDistroSeries(warty, 'mozilla-firefox')
- >>> print len(list(result))
- 3
- >>> result = binset.getByNameInDistroSeries(warty, 'nosuchpackage')
- >>> print len(list(result))
- 0
- >>> result = binset.getByNameInDistroSeries(
- ... warty, 'mozilla-firefox', version='0.9')
- >>> print len(list(result))
- 2
- >>> result = binset.getByNameInDistroSeries(
- ... warty, 'mozilla-firefox', version='nosuchversion')
- >>> print len(list(result))
- 0
- >>> result = binset.getByNameInDistroSeries(
- ... warty, 'mozilla-firefox', archtag='i386')
- >>> print len(list(result))
- 2
- >>> result = binset.getByNameInDistroSeries(
- ... warty, 'mozilla-firefox', archtag='nosucharch')
- >>> print len(list(result))
- 0
-
-XXX: bug 5947, still lacking tests for getByNameVersion, getByArchTag,
- getDistroSeriesPackages and getBySourceName -- kiko, 2006-02-22
-
-
== Binary file association ==
BinaryPackageRelease.addFile() associate given `LibraryFileAlias` with
=== modified file 'lib/lp/soyuz/interfaces/binarypackagerelease.py'
--- lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-30 19:06:34 +0000
+++ lib/lp/soyuz/interfaces/binarypackagerelease.py 2011-01-04 02:49:57 +0000
@@ -10,7 +10,6 @@
__all__ = [
'IBinaryPackageRelease',
'IBinaryPackageReleaseDownloadCount',
- 'IBinaryPackageReleaseSet',
]
from lazr.restful.declarations import (
@@ -111,18 +110,6 @@
"""
-class IBinaryPackageReleaseSet(Interface):
- """A set of binary packages"""
-
- def findByNameInDistroSeries(distroseries, pattern,
- archtag=None, fti=False):
- """Returns a set of binarypackagereleases that matchs pattern
- inside a distroseries"""
-
- def getByNameInDistroSeries(distroseries, name):
- """Get an BinaryPackageRelease in a DistroSeries by its name"""
-
-
class IBinaryPackageReleaseDownloadCount(Interface):
"""Daily download count of a binary package release in an archive."""
export_as_webservice_entry()
=== modified file 'lib/lp/soyuz/model/binarypackagerelease.py'
--- lib/lp/soyuz/model/binarypackagerelease.py 2010-08-30 19:06:34 +0000
+++ lib/lp/soyuz/model/binarypackagerelease.py 2011-01-04 02:49:57 +0000
@@ -7,7 +7,6 @@
__all__ = [
'BinaryPackageRelease',
'BinaryPackageReleaseDownloadCount',
- 'BinaryPackageReleaseSet',
]
@@ -45,7 +44,6 @@
from lp.soyuz.interfaces.binarypackagerelease import (
IBinaryPackageRelease,
IBinaryPackageReleaseDownloadCount,
- IBinaryPackageReleaseSet,
)
from lp.soyuz.model.files import BinaryPackageFile
@@ -167,84 +165,6 @@
self.priority = priority
-class BinaryPackageReleaseSet:
- """A Set of BinaryPackageReleases."""
- implements(IBinaryPackageReleaseSet)
-
- def findByNameInDistroSeries(self, distroseries, pattern, archtag=None,
- fti=False):
- """Returns a set of binarypackagereleases that matchs pattern inside a
- distroseries.
- """
- pattern = pattern.replace('%', '%%')
- query, clauseTables = self._buildBaseQuery(distroseries)
- queries = [query]
-
- match_query = ("BinaryPackageName.name LIKE lower('%%' || %s || '%%')"
- % (quote_like(pattern)))
- if fti:
- match_query = ("(%s OR BinaryPackageRelease.fti @@ ftq(%s))"
- % (match_query, quote(pattern)))
- queries.append(match_query)
-
- if archtag:
- queries.append('DistroArchSeries.architecturetag=%s'
- % sqlvalues(archtag))
-
- query = " AND ".join(queries)
-
- return BinaryPackageRelease.select(query, clauseTables=clauseTables,
- orderBy='BinaryPackageName.name')
-
- def getByNameInDistroSeries(self, distroseries, name=None,
- version=None, archtag=None, orderBy=None):
- """Get a BinaryPackageRelease in a DistroSeries by its name."""
- query, clauseTables = self._buildBaseQuery(distroseries)
- queries = [query]
-
- if name:
- queries.append('BinaryPackageName.name = %s'% sqlvalues(name))
-
- # Look for a specific binarypackage version or if version == None
- # return the current one
- if version:
- queries.append('BinaryPackageRelease.version = %s'
- % sqlvalues(version))
- else:
- status_published = PackagePublishingStatus.PUBLISHED
- queries.append('BinaryPackagePublishingHistory.status = %s'
- % sqlvalues(status_published))
-
- if archtag:
- queries.append('DistroArchSeries.architecturetag = %s'
- % sqlvalues(archtag))
-
- query = " AND ".join(queries)
- return BinaryPackageRelease.select(query, distinct=True,
- clauseTables=clauseTables,
- orderBy=orderBy)
-
- def _buildBaseQuery(self, distroseries):
- query = """
- BinaryPackagePublishingHistory.binarypackagerelease =
- BinaryPackageRelease.id AND
- BinaryPackagePublishingHistory.distroarchseries =
- DistroArchSeries.id AND
- BinaryPackagePublishingHistory.archive IN %s AND
- DistroArchSeries.distroseries = %s AND
- BinaryPackageRelease.binarypackagename =
- BinaryPackageName.id AND
- BinaryPackagePublishingHistory.dateremoved is NULL
- """ % sqlvalues([archive.id for archive in
- distroseries.distribution.all_distro_archives],
- distroseries)
-
- clauseTables = ['BinaryPackagePublishingHistory', 'DistroArchSeries',
- 'BinaryPackageRelease', 'BinaryPackageName']
-
- return query, clauseTables
-
-
class BinaryPackageReleaseDownloadCount(Storm):
"""See `IBinaryPackageReleaseDownloadCount`."""
=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py 2010-11-06 12:08:24 +0000
+++ lib/lp/soyuz/model/distroarchseries.py 2011-01-04 02:49:57 +0000
@@ -47,7 +47,6 @@
from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName
-from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet
from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
from lp.soyuz.interfaces.distroarchseries import (
IDistroArchSeries,
@@ -177,12 +176,6 @@
return pocket_chroot
- def findPackagesByName(self, pattern, fti=False):
- """Search BinaryPackages matching pattern and archtag"""
- binset = getUtility(IBinaryPackageReleaseSet)
- return binset.findByNameInDistroSeries(
- self.distroseries, pattern, self.architecturetag, fti)
-
def searchBinaryPackages(self, text):
"""See `IDistroArchSeries`."""
store = getUtility(IStoreSelector).get(MAIN_STORE, SLAVE_FLAVOR)
=== modified file 'lib/lp/soyuz/scripts/ftpmaster.py'
--- lib/lp/soyuz/scripts/ftpmaster.py 2010-12-23 13:20:28 +0000
+++ lib/lp/soyuz/scripts/ftpmaster.py 2011-01-04 02:49:57 +0000
@@ -61,7 +61,6 @@
PackageLocationError,
)
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
-from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet
from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.scripts.ftpmasterbase import (
SoyuzScript,
@@ -332,9 +331,7 @@
Ensure the package is still published in the suite before add.
"""
- bpr = getUtility(IBinaryPackageReleaseSet)
- result = bpr.getByNameInDistroSeries(
- self.distroseries, package)
+ result = self.distroseries.getBinaryPackagePublishing(name=package)
if len(list(result)) == 0:
return