← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/destroy-publishedpackage into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/destroy-publishedpackage into lp:launchpad.

Requested reviews:
  Robert Collins (lifeless): db
  Stuart Bishop (stub)
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #613686 Distribution.guessPackageNames is slow
  https://bugs.launchpad.net/bugs/613686


Bug #608037 and bug #609012 are partially caused by the slowness of Distribution.guessPackageNames. It's slow because it uses the PublishedPackage view, which joins some 13 tables together, many of which are irrelevant.

I've fixed Distribution.guessPackageNames to construct queries over the base tables, avoiding the massive view. This removes most of the joins, resulting in a much more pleasant query plan.

It turns out that the method was one of just two remaining users of PublishedPackage: the other being create-debwatches.py, which was created five years ago and hasn't ever been used, and has no tests. It also seems to be somewhat broken, so I just ported it to an equivalent method and am going to pretend that it still works.

With all the users gone, I've also dropped the PublishedPackage view and code itself.
-- 
https://code.launchpad.net/~wgrant/launchpad/destroy-publishedpackage/+merge/31813
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/destroy-publishedpackage into lp:launchpad.
=== modified file 'cronscripts/create-debwatches.py'
--- cronscripts/create-debwatches.py	2010-04-27 19:48:39 +0000
+++ cronscripts/create-debwatches.py	2010-08-05 02:50:58 +0000
@@ -77,9 +77,9 @@
 
         # first find all the published ubuntu packages
         ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
-        for p in ubuntu.currentrelease.publishedBinaryPackages(
-            component='main'):
-            target_package_set.add(p.binarypackagename.name)
+        for p in ubuntu.currentrelease.getAllPublishedBinaries():
+            target_package_set.add(
+                p.binarypackagerelease.binarypackagename.name)
         # then add packages passed on the command line
         for package in self.options.packages:
             target_package_set.add(package)

=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql	2010-08-04 00:03:20 +0000
+++ database/schema/comments.sql	2010-08-05 02:50:58 +0000
@@ -1113,14 +1113,6 @@
 COMMENT ON COLUMN BinaryPackagePublishingHistory.removed_by IS 'Person responsible for the removal.';
 COMMENT ON COLUMN BinaryPackagePublishingHistory.removal_comment IS 'Reason why the publication was removed.';
 
--- PublishedPackage View
-
-COMMENT ON VIEW PublishedPackage IS
-    'A very large view that brings together all the information about
-    packages that are currently being published within a distribution. This
-    view was designed for the page which shows packages published in the
-    distribution, but may be more widely used.';
-
 -- ProcessorFamily
 
 COMMENT ON TABLE ProcessorFamily IS 'An architecture, that might consist of several actual processors. Different distributions call these architectures different things, so we have an "architecturetag" in DistroArchSeries that might be different to the architecture''s name.';

=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2010-08-03 11:15:14 +0000
+++ database/schema/security.cfg	2010-08-05 02:50:58 +0000
@@ -859,7 +859,6 @@
 public.sourcepackagerecipebuildjob              = SELECT, INSERT, UPDATE, DELETE
 public.sourcepackagerecipedata                  = SELECT
 public.sourcepackagerecipedatainstruction       = SELECT
-public.publishedpackage                         = SELECT
 public.person                                   = SELECT
 public.emailaddress                             = SELECT
 public.teammembership                           = SELECT
@@ -975,7 +974,6 @@
 public.productsvnmodule                 = SELECT, INSERT, UPDATE
 public.project                          = SELECT, INSERT, UPDATE
 public.projectrelationship              = SELECT, INSERT, UPDATE
-public.publishedpackage                 = SELECT
 public.pushmirroraccess                 = SELECT, INSERT, UPDATE
 public.section                          = SELECT, INSERT, UPDATE
 public.sectionselection                 = SELECT, INSERT, UPDATE

=== modified file 'lib/canonical/launchpad/browser/__init__.py'
--- lib/canonical/launchpad/browser/__init__.py	2010-04-01 18:47:24 +0000
+++ lib/canonical/launchpad/browser/__init__.py	2010-08-05 02:50:58 +0000
@@ -46,7 +46,6 @@
 from canonical.launchpad.browser.packagerelationship import *
 from lp.registry.browser.peoplemerge import *
 from lp.registry.browser.poll import *
-from lp.soyuz.browser.publishedpackage import *
 from lp.soyuz.browser.publishing import *
 from lp.answers.browser.question import *
 from lp.answers.browser.questiontarget import *

=== modified file 'lib/canonical/launchpad/database/__init__.py'
--- lib/canonical/launchpad/database/__init__.py	2010-04-12 08:29:02 +0000
+++ lib/canonical/launchpad/database/__init__.py	2010-08-05 02:50:58 +0000
@@ -11,7 +11,6 @@
 from lp.soyuz.model.sourcepackagerelease import *
 from lp.soyuz.model.binarypackagerelease import *
 from lp.soyuz.model.binarypackagename import *
-from lp.soyuz.model.publishedpackage import *
 from lp.soyuz.model.distributionsourcepackagerelease import *
 from lp.soyuz.model.distroseriesbinarypackage import *
 from lp.soyuz.model.distroseriespackagecache import *

=== modified file 'lib/canonical/launchpad/interfaces/__init__.py'
--- lib/canonical/launchpad/interfaces/__init__.py	2010-07-07 19:41:07 +0000
+++ lib/canonical/launchpad/interfaces/__init__.py	2010-08-05 02:50:58 +0000
@@ -102,7 +102,6 @@
 from lp.registry.interfaces.productrelease import *
 from lp.registry.interfaces.productseries import *
 from lp.registry.interfaces.projectgroup import *
-from lp.soyuz.interfaces.publishedpackage import *
 from lp.soyuz.interfaces.publishing import *
 from lp.soyuz.interfaces.queue import *
 from canonical.launchpad.interfaces.schema import *

=== modified file 'lib/lp/registry/browser/distribution.py'
--- lib/lp/registry/browser/distribution.py	2010-08-02 02:13:52 +0000
+++ lib/lp/registry/browser/distribution.py	2010-08-05 02:50:58 +0000
@@ -71,15 +71,13 @@
     IDistributionMirrorSet, MirrorContent, MirrorSpeed)
 from lp.registry.interfaces.series import SeriesStatus
 from lp.registry.interfaces.product import IProduct
-from lp.soyuz.interfaces.publishedpackage import (
-    IPublishedPackageSet)
 from lp.registry.browser.structuralsubscription import (
     StructuralSubscriptionTargetTraversalMixin)
 from canonical.launchpad.webapp import (
     action, ApplicationMenu, canonical_url, ContextMenu, custom_widget,
     enabled_with_permission, GetitemNavigation,
     LaunchpadFormView, LaunchpadView, Link, Navigation, redirection,
-    StandardLaunchpadFacets, stepthrough, stepto)
+    StandardLaunchpadFacets, stepthrough)
 from canonical.launchpad.webapp.interfaces import ILaunchBag
 from canonical.launchpad.helpers import english_list
 from canonical.launchpad.webapp import NavigationMenu
@@ -134,10 +132,6 @@
     def redirect_source(self):
         return canonical_url(self.context)
 
-    @stepto('+packages')
-    def packages(self):
-        return getUtility(IPublishedPackageSet)
-
     @stepthrough('+mirror')
     def traverse_mirrors(self, name):
         return self.context.getMirrorByName(name)

=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py	2010-08-03 22:03:56 +0000
+++ lib/lp/registry/interfaces/distroseries.py	2010-08-05 02:50:58 +0000
@@ -554,12 +554,6 @@
         Return a SelectResult of SourcePackagePublishingHistory.
         """
 
-    def publishedBinaryPackages(component=None):
-        """Given an optional component name, return a list of the binary
-        packages that are currently published in this distroseries in the
-        given component, or in any component if no component name was given.
-        """
-
     def getDistroSeriesLanguage(language):
         """Return the DistroSeriesLanguage for this distroseries and the
         given language, or None if there's no DistroSeriesLanguage for this

=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py	2010-08-04 09:39:04 +0000
+++ lib/lp/registry/model/distribution.py	2010-08-05 02:50:58 +0000
@@ -29,6 +29,7 @@
 from canonical.launchpad.components.decoratedresultset import (
     DecoratedResultSet)
 from canonical.launchpad.components.storm_operators import FTQ, Match, RANK
+from canonical.launchpad.interfaces.lpstorm import IStore
 from canonical.lazr.utils import safe_hasattr
 from lp.registry.model.announcement import MakesAnnouncements
 from lp.soyuz.model.archive import Archive
@@ -59,7 +60,6 @@
 from lp.registry.model.milestone import (
     HasMilestonesMixin, Milestone)
 from lp.registry.model.pillar import HasAliasMixin
-from lp.soyuz.model.publishedpackage import PublishedPackage
 from lp.soyuz.model.publishing import (
     BinaryPackageFilePublishing, BinaryPackagePublishingHistory,
     SourcePackageFilePublishing, SourcePackagePublishingHistory)
@@ -1172,6 +1172,17 @@
         # instance, when people file bugs, it might actually be bad for
         # us to allow them to be associated with obsolete packages.
 
+        bpph_location_clauses = [
+            DistroSeries.distribution == self,
+            DistroArchSeries.distroseriesID == DistroSeries.id,
+            BinaryPackagePublishingHistory.distroarchseriesID ==
+                DistroArchSeries.id,
+            BinaryPackagePublishingHistory.archiveID.is_in(
+                self.all_distro_archive_ids),
+            BinaryPackageRelease.id ==
+                BinaryPackagePublishingHistory.binarypackagereleaseID,
+            ]
+
         sourcepackagename = SourcePackageName.selectOneBy(name=pkgname)
         if sourcepackagename:
             # Note that in the source package case, we don't restrict
@@ -1197,20 +1208,21 @@
             if publishing is not None:
                 # Attempt to find a published binary package of the
                 # same name.
-                publishedpackage = PublishedPackage.selectFirst('''
-                    PublishedPackage.sourcepackagename = %s AND
-                    PublishedPackage.binarypackagename = %s AND
-                    PublishedPackage.distribution = %s AND
-                    PublishedPackage.archive IN %s
-                    ''' % sqlvalues(sourcepackagename.name,
-                                    sourcepackagename.name,
-                                    self,
-                                    self.all_distro_archive_ids),
-                    orderBy=['-id'])
-                if publishedpackage is not None:
-                    binarypackagename = BinaryPackageName.byName(
-                        publishedpackage.binarypackagename)
-                    return (sourcepackagename, binarypackagename)
+                bpph = IStore(BinaryPackagePublishingHistory).find(
+                    BinaryPackagePublishingHistory,
+                    BinaryPackageRelease.binarypackagename ==
+                        BinaryPackageName.id,
+                    BinaryPackageName.name == sourcepackagename.name,
+                    BinaryPackageBuild.id == BinaryPackageRelease.buildID,
+                    SourcePackageRelease.id ==
+                        BinaryPackageBuild.source_package_release_id,
+                    SourcePackageRelease.sourcepackagename ==
+                        sourcepackagename,
+                    *bpph_location_clauses).order_by(
+                        BinaryPackagePublishingHistory.id).first()
+                if bpph is not None:
+                    bpr = bpph.binarypackagerelease
+                    return (sourcepackagename, bpr.binarypackagename)
                 # No binary with a similar name, so just return None
                 # rather than returning some arbitrary binary package.
                 return (sourcepackagename, None)
@@ -1224,18 +1236,14 @@
             # latest publication in the distribution (this may be an old
             # package name the end-user is groping for) -- and then get
             # the sourcepackagename from that.
-            publishing = PublishedPackage.selectFirst('''
-                PublishedPackage.binarypackagename = %s AND
-                PublishedPackage.distribution = %s AND
-                PublishedPackage.archive IN %s
-                ''' % sqlvalues(binarypackagename.name,
-                                self,
-                                self.all_distro_archive_ids),
-                orderBy=['-id'])
-            if publishing is not None:
-                sourcepackagename = SourcePackageName.byName(
-                                        publishing.sourcepackagename)
-                return (sourcepackagename, binarypackagename)
+            bpph = IStore(BinaryPackagePublishingHistory).find(
+                BinaryPackagePublishingHistory,
+                BinaryPackageRelease.binarypackagename == binarypackagename,
+                *bpph_location_clauses).order_by(
+                    BinaryPackagePublishingHistory.id).first()
+            if bpph is not None:
+                spr = bpph.binarypackagerelease.build.source_package_release
+                return (spr.sourcepackagename, binarypackagename)
 
         # We got nothing so signal an error.
         if sourcepackagename is None:

=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py	2010-08-02 02:13:52 +0000
+++ lib/lp/registry/model/distroseries.py	2010-08-05 02:50:58 +0000
@@ -104,8 +104,6 @@
 from lp.translations.interfaces.languagepack import LanguagePackType
 from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
 from lp.soyuz.interfaces.queue import PackageUploadStatus
-from lp.soyuz.interfaces.publishedpackage import (
-    IPublishedPackageSet)
 from lp.soyuz.interfaces.publishing import (
     active_publishing_status, ICanPublishPackages, PackagePublishingStatus)
 from lp.soyuz.interfaces.queue import IHasQueueItems, IPackageUploadSet
@@ -1093,15 +1091,6 @@
 
         return result
 
-    def publishedBinaryPackages(self, component=None):
-        """See `IDistroSeries`."""
-        # XXX sabdfl 2005-07-04: This can become a utility when that works
-        # this is used by the debbugs import process, mkdebwatches
-        pubpkgset = getUtility(IPublishedPackageSet)
-        result = pubpkgset.query(distroseries=self, component=component)
-        return [BinaryPackageRelease.get(pubrecord.binarypackagerelease)
-                for pubrecord in result]
-
     def getBuildRecords(self, build_state=None, name=None, pocket=None,
                         arch_tag=None, user=None, binary_only=True):
         """See IHasBuildRecords"""

=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml	2010-06-30 17:35:36 +0000
+++ lib/lp/soyuz/configure.zcml	2010-08-05 02:50:58 +0000
@@ -545,34 +545,6 @@
         factory="canonical.launchpad.webapp.breadcrumb.NameBreadcrumb"
         permission="zope.Public" />
 
-    <!-- PublishedPackage -->
-
-    <class
-        class="canonical.launchpad.database.PublishedPackage">
-        <allow
-            interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackage"/>
-        <require
-            permission="zope.Public"
-            set_schema="lp.soyuz.interfaces.publishedpackage.IPublishedPackage"/>
-    </class>
-
-    <!-- PublishedPackageSet -->
-
-    <class
-        class="canonical.launchpad.database.PublishedPackageSet">
-        <allow
-            interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
-        <require
-            permission="zope.Public"
-            set_schema="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
-    </class>
-    <securedutility
-        provides="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"
-        class="canonical.launchpad.database.PublishedPackageSet">
-        <allow
-            interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
-    </securedutility>
-
     <!-- ArchiveSubscriber -->
 
     <class

=== removed file 'lib/lp/soyuz/doc/publishedpackage.txt'
--- lib/lp/soyuz/doc/publishedpackage.txt	2009-04-28 12:59:43 +0000
+++ lib/lp/soyuz/doc/publishedpackage.txt	1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-= Published Package =
-
-This database view gives us information on which packages are published in
-which distributions.
-
-    >>> from zope.component import getUtility
-    >>> from canonical.launchpad.interfaces import IPublishedPackageSet
-    >>> pp_set = getUtility(IPublishedPackageSet)
-
-    >>> from canonical.launchpad.webapp.testing import verifyObject
-    >>> verifyObject(IPublishedPackageSet, pp_set)
-    True
-
-IDistroSeriesSourcePackageRelease.meta_binaries returns a list of unique
-binaries resulting from the sourcepackagerelease for a distroseries.
-The source package mozilla-firefox has two unique binaries:
-"mozilla-firefox-data" and "mozilla-firefox". Although the latter
-is published twice in two architectures it is only returned once.
-
-    >>> from canonical.launchpad.interfaces import IDistributionSet
-    >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
-    >>> warty = ubuntu['warty']
-    >>> ff_sp = warty.getSourcePackage('mozilla-firefox')
-    >>> ff_drspr = ff_sp['0.9']
-    >>> for package in ff_drspr.meta_binaries:
-    ...     print package.name
-    mozilla-firefox
-    mozilla-firefox-data
-
-    >>> from canonical.launchpad.interfaces import IDistroSeriesBinaryPackage
-    >>> verifyObject(IDistroSeriesBinaryPackage, ff_drspr.meta_binaries[0])
-    True

=== modified file 'lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py'
--- lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py	2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py	2010-08-05 02:50:58 +0000
@@ -56,10 +56,6 @@
         "Return binaries resulted from this sourcepackagerelease and  "
         "published in this distroseries.")
 
-    meta_binaries = Attribute(
-        "A list of distinct meta binaries built from this "
-        "sourcepackagerelease and published in this distroseries.")
-
     current_published = Attribute("is last SourcePackagePublishing record "
                                   "that is in PUBLISHED status.")
 

=== removed file 'lib/lp/soyuz/interfaces/publishedpackage.py'
--- lib/lp/soyuz/interfaces/publishedpackage.py	2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/interfaces/publishedpackage.py	1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0211,E0213
-
-"""Published package interfaces."""
-
-__metaclass__ = type
-
-__all__ = [
-    'IPublishedPackage',
-    'IPublishedPackageSet',
-    ]
-
-from zope.interface import Interface, Attribute
-from canonical.launchpad import _
-
-
-class IPublishedPackage(Interface):
-    """NOT A TABLE: this is a large database view which gives us a lot of
-    de-normalised, but very useful information about packages which have
-    been published in a distribution."""
-
-    id = Attribute("The id of the packagepublishing record")
-    archive = Attribute("The archive where the package is published.")
-    distribution = Attribute("The distribution id")
-    distroarchseries = Attribute("The distroarchseries.")
-    distroseries = Attribute("The distribution series id")
-    distroseriesname = Attribute("The distribution series name")
-    processorfamily = Attribute("The processor family id")
-    processorfamilyname = Attribute("The processor family name")
-    packagepublishingstatus = Attribute("The status of this published package")
-    component = Attribute("The component in which the package has been published")
-    section = Attribute("The section in which it is published.")
-    binarypackagerelease = Attribute("The id of the binary package in question")
-    binarypackagename = Attribute("The binary package name")
-    binarypackagesummary = Attribute("The binary package summary")
-    binarypackagedescription = Attribute("The binary package description")
-    binarypackageversion = Attribute("The binary package version")
-    build = Attribute("The build id")
-    datebuilt = Attribute("The date this package was built or uploaded")
-    sourcepackagerelease = Attribute("Source package release id")
-    sourcepackagereleaseversion = Attribute("Source package release version")
-    sourcepackagename = Attribute("Source package name")
-
-
-class IPublishedPackageSet(Interface):
-    """The set of packages that are published across all distributions"""
-
-    def __iter__():
-        """Iterate over all published packages."""
-
-    def query(name=None, text=None, distribution=None, distroseries=None,
-              distroarchseries=None, component=None):
-        """Search through published packages returning those that meet the
-        given criteria"""
-
-    def findDepCandidate(name, distroarchseries):
-        """Return the package candidate within the distroarchseries context.
-
-        Return the PublishedPackage record by bynarypackagename or None if
-        not found.
-        """

=== modified file 'lib/lp/soyuz/model/distroseriessourcepackagerelease.py'
--- lib/lp/soyuz/model/distroseriessourcepackagerelease.py	2010-05-14 07:20:41 +0000
+++ lib/lp/soyuz/model/distroseriessourcepackagerelease.py	2010-08-05 02:50:58 +0000
@@ -147,15 +147,6 @@
                 distinct=True)
 
     @property
-    def meta_binaries(self):
-        """See `IDistroSeriesSourcePackageRelease`."""
-        binary_pkg_names = sorted(
-            set([pkg.binarypackagename for pkg in self.binaries]),
-            key=attrgetter('name'))
-        return [self.distroseries.getBinaryPackage(name)
-                for name in binary_pkg_names]
-
-    @property
     def changesfile(self):
         """See `IDistroSeriesSourcePackageRelease`."""
         return self.sourcepackagerelease.upload_changesfile

=== removed file 'lib/lp/soyuz/model/publishedpackage.py'
--- lib/lp/soyuz/model/publishedpackage.py	2010-04-12 11:37:48 +0000
+++ lib/lp/soyuz/model/publishedpackage.py	1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0611,W0212
-
-__metaclass__ = type
-__all__ = ['PublishedPackage', 'PublishedPackageSet']
-
-from zope.interface import implements
-
-from sqlobject import StringCol, ForeignKey
-
-from canonical.database.sqlbase import SQLBase, quote, quote_like
-from canonical.database.datetimecol import UtcDateTimeCol
-from canonical.database.enumcol import EnumCol
-
-from lp.soyuz.interfaces.publishedpackage import (
-    IPublishedPackage, IPublishedPackageSet)
-from lp.soyuz.interfaces.publishing import PackagePublishingStatus
-
-
-class PublishedPackage(SQLBase):
-    """See IPublishedPackage for details."""
-
-    implements(IPublishedPackage)
-
-    _table = 'PublishedPackage'
-
-    archive = ForeignKey(
-        dbName='archive', foreignKey='Archive', immutable=True)
-    distribution = ForeignKey(dbName='distribution',
-                              foreignKey='Distribution',
-                              immutable=True)
-    distroarchseries = ForeignKey(dbName='distroarchseries',
-                                   foreignKey='DistroArchSeries',
-                                   immutable=True)
-    distroseries = ForeignKey(dbName='distroseries',
-                               foreignKey='DistroSeries',
-                               immutable=True)
-    distroseriesname = StringCol(dbName='distroseriesname', immutable=True)
-    processorfamily = ForeignKey(dbName="processorfamily",
-                                 foreignKey="ProcessorFamily",
-                                 immutable=True)
-    processorfamilyname = StringCol(immutable=True)
-    packagepublishingstatus = EnumCol(immutable=True,
-                                      schema=PackagePublishingStatus)
-    component = StringCol(immutable=True)
-    section = StringCol(immutable=True)
-    binarypackagerelease = ForeignKey(dbName="binarypackagerelease",
-                                      foreignKey="BinaryPackageRelease",
-                                      immutable=True)
-    binarypackagename = StringCol(immutable=True)
-    binarypackagesummary = StringCol(immutable=True)
-    binarypackagedescription = StringCol(immutable=True)
-    binarypackageversion = StringCol(immutable=True)
-    build = ForeignKey(foreignKey='BinaryPackageBuild', dbName='build')
-    datebuilt = UtcDateTimeCol(immutable=True)
-    sourcepackagerelease = ForeignKey(dbName="sourcepackagerelease",
-                                      foreignKey="SourcePackageRelease",
-                                      immutable=True)
-    sourcepackagereleaseversion = StringCol(immutable=True)
-    sourcepackagename = StringCol(immutable=True)
-
-
-class PublishedPackageSet:
-
-    implements(IPublishedPackageSet)
-
-    def __iter__(self):
-        return iter(PublishedPackage.select())
-
-    def query(self, name=None, text=None, distribution=None,
-              distroseries=None, distroarchseries=None, component=None):
-        queries = []
-        if name:
-            name = name.lower().strip().split()[0]
-            queries.append("binarypackagename ILIKE '%%' || %s || '%%'"
-                           % quote_like(name))
-        if distribution:
-            queries.append("distribution = %d" % distribution.id)
-        if distroseries:
-            queries.append("distroseries = %d" % distroseries.id)
-        if distroarchseries:
-            queries.append("distroarchseries = %d" % distroarchseries.id)
-        if component:
-            queries.append("component = %s" % quote(component))
-        if text:
-            text = text.lower().strip()
-            queries.append("binarypackagefti @@ ftq(%s)" % quote(text))
-        return PublishedPackage.select(
-            " AND ".join(queries), orderBy=['-datebuilt',])
-
-    def findDepCandidate(self, name, distroarchseries):
-        """See IPublishedSet."""
-        return PublishedPackage.selectOneBy(binarypackagename=name,
-                                            distroarchseries=distroarchseries)


Follow ups