Merge lp:~wgrant/launchpad/destroy-publishedpackage into lp:launchpad/db-devel

Proposed by William Grant
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 9628
Proposed branch: lp:~wgrant/launchpad/destroy-publishedpackage
Merge into: lp:launchpad/db-devel
Diff against target: 562 lines (+46/-299)
17 files modified
cronscripts/create-debwatches.py (+3/-3)
database/schema/comments.sql (+0/-8)
database/schema/patch-2207-80-0.sql (+8/-0)
database/schema/security.cfg (+0/-2)
lib/canonical/launchpad/browser/__init__.py (+0/-1)
lib/canonical/launchpad/database/__init__.py (+0/-1)
lib/canonical/launchpad/interfaces/__init__.py (+0/-1)
lib/lp/registry/browser/distribution.py (+1/-7)
lib/lp/registry/interfaces/distroseries.py (+0/-6)
lib/lp/registry/model/distribution.py (+34/-27)
lib/lp/registry/model/distroseries.py (+0/-11)
lib/lp/soyuz/configure.zcml (+0/-28)
lib/lp/soyuz/doc/publishedpackage.txt (+0/-32)
lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py (+0/-4)
lib/lp/soyuz/interfaces/publishedpackage.py (+0/-63)
lib/lp/soyuz/model/distroseriessourcepackagerelease.py (+0/-9)
lib/lp/soyuz/model/publishedpackage.py (+0/-96)
To merge this branch: bzr merge lp:~wgrant/launchpad/destroy-publishedpackage
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Robert Collins (community) Approve
Launchpad code reviewers Pending
Review via email: mp+31813@code.launchpad.net

Commit message

Distribution.guessPackageNames is now much faster, and the mammoth PublishedPackage view is gone.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

So this drops the metadata, but won't actually drop the view - I presume you're going to merge to devel to fix the oops, and separately merge a 'drop the view' db patch to db-devel? Except, oddly, this is proposed to db-devel.

So I suggest you do the above :)

Other than that, great.

review: Needs Fixing
Revision history for this message
William Grant (wgrant) wrote :

I forgot to bzr add the DB patch. Fixed.

Revision history for this message
Robert Collins (lifeless) wrote :

Looks good to me

review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

DB patch is fine. patch-2207-80-0.sql

review: Approve (db)
Revision history for this message
Stuart Bishop (stub) wrote :

Code changes look good.

The queries in lib/lp/registry/model/distribution.py used to return 'latest' and now return 'first' - previously they were sorting by id descending and now ascending. This may be a bug.

Revision history for this message
William Grant (wgrant) wrote :

It doesn't matter at all, as it turns out. I've replaced it with an any().

Revision history for this message
Julian Edwards (julian-edwards) wrote :

I am so happy to see another view biting the dust.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cronscripts/create-debwatches.py'
--- cronscripts/create-debwatches.py 2010-04-27 19:48:39 +0000
+++ cronscripts/create-debwatches.py 2010-08-05 22:12:56 +0000
@@ -77,9 +77,9 @@
7777
78 # first find all the published ubuntu packages78 # first find all the published ubuntu packages
79 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu79 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
80 for p in ubuntu.currentrelease.publishedBinaryPackages(80 for p in ubuntu.currentrelease.getAllPublishedBinaries():
81 component='main'):81 target_package_set.add(
82 target_package_set.add(p.binarypackagename.name)82 p.binarypackagerelease.binarypackagename.name)
83 # then add packages passed on the command line83 # then add packages passed on the command line
84 for package in self.options.packages:84 for package in self.options.packages:
85 target_package_set.add(package)85 target_package_set.add(package)
8686
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2010-08-05 02:29:25 +0000
+++ database/schema/comments.sql 2010-08-05 22:12:56 +0000
@@ -1113,14 +1113,6 @@
1113COMMENT ON COLUMN BinaryPackagePublishingHistory.removed_by IS 'Person responsible for the removal.';1113COMMENT ON COLUMN BinaryPackagePublishingHistory.removed_by IS 'Person responsible for the removal.';
1114COMMENT ON COLUMN BinaryPackagePublishingHistory.removal_comment IS 'Reason why the publication was removed.';1114COMMENT ON COLUMN BinaryPackagePublishingHistory.removal_comment IS 'Reason why the publication was removed.';
11151115
1116-- PublishedPackage View
1117
1118COMMENT ON VIEW PublishedPackage IS
1119 'A very large view that brings together all the information about
1120 packages that are currently being published within a distribution. This
1121 view was designed for the page which shows packages published in the
1122 distribution, but may be more widely used.';
1123
1124-- ProcessorFamily1116-- ProcessorFamily
11251117
1126COMMENT 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.';1118COMMENT 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.';
11271119
=== added file 'database/schema/patch-2207-80-0.sql'
--- database/schema/patch-2207-80-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2207-80-0.sql 2010-08-05 22:12:56 +0000
@@ -0,0 +1,8 @@
1-- Copyright 2010 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6DROP VIEW PublishedPackage;
7
8INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 80, 0);
09
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2010-08-03 11:15:14 +0000
+++ database/schema/security.cfg 2010-08-05 22:12:56 +0000
@@ -859,7 +859,6 @@
859public.sourcepackagerecipebuildjob = SELECT, INSERT, UPDATE, DELETE859public.sourcepackagerecipebuildjob = SELECT, INSERT, UPDATE, DELETE
860public.sourcepackagerecipedata = SELECT860public.sourcepackagerecipedata = SELECT
861public.sourcepackagerecipedatainstruction = SELECT861public.sourcepackagerecipedatainstruction = SELECT
862public.publishedpackage = SELECT
863public.person = SELECT862public.person = SELECT
864public.emailaddress = SELECT863public.emailaddress = SELECT
865public.teammembership = SELECT864public.teammembership = SELECT
@@ -975,7 +974,6 @@
975public.productsvnmodule = SELECT, INSERT, UPDATE974public.productsvnmodule = SELECT, INSERT, UPDATE
976public.project = SELECT, INSERT, UPDATE975public.project = SELECT, INSERT, UPDATE
977public.projectrelationship = SELECT, INSERT, UPDATE976public.projectrelationship = SELECT, INSERT, UPDATE
978public.publishedpackage = SELECT
979public.pushmirroraccess = SELECT, INSERT, UPDATE977public.pushmirroraccess = SELECT, INSERT, UPDATE
980public.section = SELECT, INSERT, UPDATE978public.section = SELECT, INSERT, UPDATE
981public.sectionselection = SELECT, INSERT, UPDATE979public.sectionselection = SELECT, INSERT, UPDATE
982980
=== 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 22:12:56 +0000
@@ -46,7 +46,6 @@
46from canonical.launchpad.browser.packagerelationship import *46from canonical.launchpad.browser.packagerelationship import *
47from lp.registry.browser.peoplemerge import *47from lp.registry.browser.peoplemerge import *
48from lp.registry.browser.poll import *48from lp.registry.browser.poll import *
49from lp.soyuz.browser.publishedpackage import *
50from lp.soyuz.browser.publishing import *49from lp.soyuz.browser.publishing import *
51from lp.answers.browser.question import *50from lp.answers.browser.question import *
52from lp.answers.browser.questiontarget import *51from lp.answers.browser.questiontarget import *
5352
=== 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 22:12:56 +0000
@@ -11,7 +11,6 @@
11from lp.soyuz.model.sourcepackagerelease import *11from lp.soyuz.model.sourcepackagerelease import *
12from lp.soyuz.model.binarypackagerelease import *12from lp.soyuz.model.binarypackagerelease import *
13from lp.soyuz.model.binarypackagename import *13from lp.soyuz.model.binarypackagename import *
14from lp.soyuz.model.publishedpackage import *
15from lp.soyuz.model.distributionsourcepackagerelease import *14from lp.soyuz.model.distributionsourcepackagerelease import *
16from lp.soyuz.model.distroseriesbinarypackage import *15from lp.soyuz.model.distroseriesbinarypackage import *
17from lp.soyuz.model.distroseriespackagecache import *16from lp.soyuz.model.distroseriespackagecache import *
1817
=== 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 22:12:56 +0000
@@ -102,7 +102,6 @@
102from lp.registry.interfaces.productrelease import *102from lp.registry.interfaces.productrelease import *
103from lp.registry.interfaces.productseries import *103from lp.registry.interfaces.productseries import *
104from lp.registry.interfaces.projectgroup import *104from lp.registry.interfaces.projectgroup import *
105from lp.soyuz.interfaces.publishedpackage import *
106from lp.soyuz.interfaces.publishing import *105from lp.soyuz.interfaces.publishing import *
107from lp.soyuz.interfaces.queue import *106from lp.soyuz.interfaces.queue import *
108from canonical.launchpad.interfaces.schema import *107from canonical.launchpad.interfaces.schema import *
109108
=== 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 22:12:56 +0000
@@ -71,15 +71,13 @@
71 IDistributionMirrorSet, MirrorContent, MirrorSpeed)71 IDistributionMirrorSet, MirrorContent, MirrorSpeed)
72from lp.registry.interfaces.series import SeriesStatus72from lp.registry.interfaces.series import SeriesStatus
73from lp.registry.interfaces.product import IProduct73from lp.registry.interfaces.product import IProduct
74from lp.soyuz.interfaces.publishedpackage import (
75 IPublishedPackageSet)
76from lp.registry.browser.structuralsubscription import (74from lp.registry.browser.structuralsubscription import (
77 StructuralSubscriptionTargetTraversalMixin)75 StructuralSubscriptionTargetTraversalMixin)
78from canonical.launchpad.webapp import (76from canonical.launchpad.webapp import (
79 action, ApplicationMenu, canonical_url, ContextMenu, custom_widget,77 action, ApplicationMenu, canonical_url, ContextMenu, custom_widget,
80 enabled_with_permission, GetitemNavigation,78 enabled_with_permission, GetitemNavigation,
81 LaunchpadFormView, LaunchpadView, Link, Navigation, redirection,79 LaunchpadFormView, LaunchpadView, Link, Navigation, redirection,
82 StandardLaunchpadFacets, stepthrough, stepto)80 StandardLaunchpadFacets, stepthrough)
83from canonical.launchpad.webapp.interfaces import ILaunchBag81from canonical.launchpad.webapp.interfaces import ILaunchBag
84from canonical.launchpad.helpers import english_list82from canonical.launchpad.helpers import english_list
85from canonical.launchpad.webapp import NavigationMenu83from canonical.launchpad.webapp import NavigationMenu
@@ -134,10 +132,6 @@
134 def redirect_source(self):132 def redirect_source(self):
135 return canonical_url(self.context)133 return canonical_url(self.context)
136134
137 @stepto('+packages')
138 def packages(self):
139 return getUtility(IPublishedPackageSet)
140
141 @stepthrough('+mirror')135 @stepthrough('+mirror')
142 def traverse_mirrors(self, name):136 def traverse_mirrors(self, name):
143 return self.context.getMirrorByName(name)137 return self.context.getMirrorByName(name)
144138
=== 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 22:12:56 +0000
@@ -554,12 +554,6 @@
554 Return a SelectResult of SourcePackagePublishingHistory.554 Return a SelectResult of SourcePackagePublishingHistory.
555 """555 """
556556
557 def publishedBinaryPackages(component=None):
558 """Given an optional component name, return a list of the binary
559 packages that are currently published in this distroseries in the
560 given component, or in any component if no component name was given.
561 """
562
563 def getDistroSeriesLanguage(language):557 def getDistroSeriesLanguage(language):
564 """Return the DistroSeriesLanguage for this distroseries and the558 """Return the DistroSeriesLanguage for this distroseries and the
565 given language, or None if there's no DistroSeriesLanguage for this559 given language, or None if there's no DistroSeriesLanguage for this
566560
=== 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 22:12:56 +0000
@@ -29,6 +29,7 @@
29from canonical.launchpad.components.decoratedresultset import (29from canonical.launchpad.components.decoratedresultset import (
30 DecoratedResultSet)30 DecoratedResultSet)
31from canonical.launchpad.components.storm_operators import FTQ, Match, RANK31from canonical.launchpad.components.storm_operators import FTQ, Match, RANK
32from canonical.launchpad.interfaces.lpstorm import IStore
32from canonical.lazr.utils import safe_hasattr33from canonical.lazr.utils import safe_hasattr
33from lp.registry.model.announcement import MakesAnnouncements34from lp.registry.model.announcement import MakesAnnouncements
34from lp.soyuz.model.archive import Archive35from lp.soyuz.model.archive import Archive
@@ -59,7 +60,6 @@
59from lp.registry.model.milestone import (60from lp.registry.model.milestone import (
60 HasMilestonesMixin, Milestone)61 HasMilestonesMixin, Milestone)
61from lp.registry.model.pillar import HasAliasMixin62from lp.registry.model.pillar import HasAliasMixin
62from lp.soyuz.model.publishedpackage import PublishedPackage
63from lp.soyuz.model.publishing import (63from lp.soyuz.model.publishing import (
64 BinaryPackageFilePublishing, BinaryPackagePublishingHistory,64 BinaryPackageFilePublishing, BinaryPackagePublishingHistory,
65 SourcePackageFilePublishing, SourcePackagePublishingHistory)65 SourcePackageFilePublishing, SourcePackagePublishingHistory)
@@ -1172,6 +1172,18 @@
1172 # instance, when people file bugs, it might actually be bad for1172 # instance, when people file bugs, it might actually be bad for
1173 # us to allow them to be associated with obsolete packages.1173 # us to allow them to be associated with obsolete packages.
11741174
1175 bpph_location_clauses = [
1176 DistroSeries.distribution == self,
1177 DistroArchSeries.distroseriesID == DistroSeries.id,
1178 BinaryPackagePublishingHistory.distroarchseriesID ==
1179 DistroArchSeries.id,
1180 BinaryPackagePublishingHistory.archiveID.is_in(
1181 self.all_distro_archive_ids),
1182 BinaryPackagePublishingHistory.dateremoved == None,
1183 BinaryPackageRelease.id ==
1184 BinaryPackagePublishingHistory.binarypackagereleaseID,
1185 ]
1186
1175 sourcepackagename = SourcePackageName.selectOneBy(name=pkgname)1187 sourcepackagename = SourcePackageName.selectOneBy(name=pkgname)
1176 if sourcepackagename:1188 if sourcepackagename:
1177 # Note that in the source package case, we don't restrict1189 # Note that in the source package case, we don't restrict
@@ -1197,20 +1209,20 @@
1197 if publishing is not None:1209 if publishing is not None:
1198 # Attempt to find a published binary package of the1210 # Attempt to find a published binary package of the
1199 # same name.1211 # same name.
1200 publishedpackage = PublishedPackage.selectFirst('''1212 bpph = IStore(BinaryPackagePublishingHistory).find(
1201 PublishedPackage.sourcepackagename = %s AND1213 BinaryPackagePublishingHistory,
1202 PublishedPackage.binarypackagename = %s AND1214 BinaryPackageRelease.binarypackagename ==
1203 PublishedPackage.distribution = %s AND1215 BinaryPackageName.id,
1204 PublishedPackage.archive IN %s1216 BinaryPackageName.name == sourcepackagename.name,
1205 ''' % sqlvalues(sourcepackagename.name,1217 BinaryPackageBuild.id == BinaryPackageRelease.buildID,
1206 sourcepackagename.name,1218 SourcePackageRelease.id ==
1207 self,1219 BinaryPackageBuild.source_package_release_id,
1208 self.all_distro_archive_ids),1220 SourcePackageRelease.sourcepackagename ==
1209 orderBy=['-id'])1221 sourcepackagename,
1210 if publishedpackage is not None:1222 *bpph_location_clauses).any()
1211 binarypackagename = BinaryPackageName.byName(1223 if bpph is not None:
1212 publishedpackage.binarypackagename)1224 bpr = bpph.binarypackagerelease
1213 return (sourcepackagename, binarypackagename)1225 return (sourcepackagename, bpr.binarypackagename)
1214 # No binary with a similar name, so just return None1226 # No binary with a similar name, so just return None
1215 # rather than returning some arbitrary binary package.1227 # rather than returning some arbitrary binary package.
1216 return (sourcepackagename, None)1228 return (sourcepackagename, None)
@@ -1224,18 +1236,13 @@
1224 # latest publication in the distribution (this may be an old1236 # latest publication in the distribution (this may be an old
1225 # package name the end-user is groping for) -- and then get1237 # package name the end-user is groping for) -- and then get
1226 # the sourcepackagename from that.1238 # the sourcepackagename from that.
1227 publishing = PublishedPackage.selectFirst('''1239 bpph = IStore(BinaryPackagePublishingHistory).find(
1228 PublishedPackage.binarypackagename = %s AND1240 BinaryPackagePublishingHistory,
1229 PublishedPackage.distribution = %s AND1241 BinaryPackageRelease.binarypackagename == binarypackagename,
1230 PublishedPackage.archive IN %s1242 *bpph_location_clauses).any()
1231 ''' % sqlvalues(binarypackagename.name,1243 if bpph is not None:
1232 self,1244 spr = bpph.binarypackagerelease.build.source_package_release
1233 self.all_distro_archive_ids),1245 return (spr.sourcepackagename, binarypackagename)
1234 orderBy=['-id'])
1235 if publishing is not None:
1236 sourcepackagename = SourcePackageName.byName(
1237 publishing.sourcepackagename)
1238 return (sourcepackagename, binarypackagename)
12391246
1240 # We got nothing so signal an error.1247 # We got nothing so signal an error.
1241 if sourcepackagename is None:1248 if sourcepackagename is None:
12421249
=== 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 22:12:56 +0000
@@ -104,8 +104,6 @@
104from lp.translations.interfaces.languagepack import LanguagePackType104from lp.translations.interfaces.languagepack import LanguagePackType
105from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet105from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
106from lp.soyuz.interfaces.queue import PackageUploadStatus106from lp.soyuz.interfaces.queue import PackageUploadStatus
107from lp.soyuz.interfaces.publishedpackage import (
108 IPublishedPackageSet)
109from lp.soyuz.interfaces.publishing import (107from lp.soyuz.interfaces.publishing import (
110 active_publishing_status, ICanPublishPackages, PackagePublishingStatus)108 active_publishing_status, ICanPublishPackages, PackagePublishingStatus)
111from lp.soyuz.interfaces.queue import IHasQueueItems, IPackageUploadSet109from lp.soyuz.interfaces.queue import IHasQueueItems, IPackageUploadSet
@@ -1093,15 +1091,6 @@
10931091
1094 return result1092 return result
10951093
1096 def publishedBinaryPackages(self, component=None):
1097 """See `IDistroSeries`."""
1098 # XXX sabdfl 2005-07-04: This can become a utility when that works
1099 # this is used by the debbugs import process, mkdebwatches
1100 pubpkgset = getUtility(IPublishedPackageSet)
1101 result = pubpkgset.query(distroseries=self, component=component)
1102 return [BinaryPackageRelease.get(pubrecord.binarypackagerelease)
1103 for pubrecord in result]
1104
1105 def getBuildRecords(self, build_state=None, name=None, pocket=None,1094 def getBuildRecords(self, build_state=None, name=None, pocket=None,
1106 arch_tag=None, user=None, binary_only=True):1095 arch_tag=None, user=None, binary_only=True):
1107 """See IHasBuildRecords"""1096 """See IHasBuildRecords"""
11081097
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2010-07-12 01:34:09 +0000
+++ lib/lp/soyuz/configure.zcml 2010-08-05 22:12:56 +0000
@@ -545,34 +545,6 @@
545 factory="canonical.launchpad.webapp.breadcrumb.NameBreadcrumb"545 factory="canonical.launchpad.webapp.breadcrumb.NameBreadcrumb"
546 permission="zope.Public" />546 permission="zope.Public" />
547547
548 <!-- PublishedPackage -->
549
550 <class
551 class="canonical.launchpad.database.PublishedPackage">
552 <allow
553 interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackage"/>
554 <require
555 permission="zope.Public"
556 set_schema="lp.soyuz.interfaces.publishedpackage.IPublishedPackage"/>
557 </class>
558
559 <!-- PublishedPackageSet -->
560
561 <class
562 class="canonical.launchpad.database.PublishedPackageSet">
563 <allow
564 interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
565 <require
566 permission="zope.Public"
567 set_schema="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
568 </class>
569 <securedutility
570 provides="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"
571 class="canonical.launchpad.database.PublishedPackageSet">
572 <allow
573 interface="lp.soyuz.interfaces.publishedpackage.IPublishedPackageSet"/>
574 </securedutility>
575
576 <!-- ArchiveSubscriber -->548 <!-- ArchiveSubscriber -->
577549
578 <class550 <class
579551
=== 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 @@
1= Published Package =
2
3This database view gives us information on which packages are published in
4which distributions.
5
6 >>> from zope.component import getUtility
7 >>> from canonical.launchpad.interfaces import IPublishedPackageSet
8 >>> pp_set = getUtility(IPublishedPackageSet)
9
10 >>> from canonical.launchpad.webapp.testing import verifyObject
11 >>> verifyObject(IPublishedPackageSet, pp_set)
12 True
13
14IDistroSeriesSourcePackageRelease.meta_binaries returns a list of unique
15binaries resulting from the sourcepackagerelease for a distroseries.
16The source package mozilla-firefox has two unique binaries:
17"mozilla-firefox-data" and "mozilla-firefox". Although the latter
18is published twice in two architectures it is only returned once.
19
20 >>> from canonical.launchpad.interfaces import IDistributionSet
21 >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
22 >>> warty = ubuntu['warty']
23 >>> ff_sp = warty.getSourcePackage('mozilla-firefox')
24 >>> ff_drspr = ff_sp['0.9']
25 >>> for package in ff_drspr.meta_binaries:
26 ... print package.name
27 mozilla-firefox
28 mozilla-firefox-data
29
30 >>> from canonical.launchpad.interfaces import IDistroSeriesBinaryPackage
31 >>> verifyObject(IDistroSeriesBinaryPackage, ff_drspr.meta_binaries[0])
32 True
330
=== 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 22:12:56 +0000
@@ -56,10 +56,6 @@
56 "Return binaries resulted from this sourcepackagerelease and "56 "Return binaries resulted from this sourcepackagerelease and "
57 "published in this distroseries.")57 "published in this distroseries.")
5858
59 meta_binaries = Attribute(
60 "A list of distinct meta binaries built from this "
61 "sourcepackagerelease and published in this distroseries.")
62
63 current_published = Attribute("is last SourcePackagePublishing record "59 current_published = Attribute("is last SourcePackagePublishing record "
64 "that is in PUBLISHED status.")60 "that is in PUBLISHED status.")
6561
6662
=== 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 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# pylint: disable-msg=E0211,E0213
5
6"""Published package interfaces."""
7
8__metaclass__ = type
9
10__all__ = [
11 'IPublishedPackage',
12 'IPublishedPackageSet',
13 ]
14
15from zope.interface import Interface, Attribute
16from canonical.launchpad import _
17
18
19class IPublishedPackage(Interface):
20 """NOT A TABLE: this is a large database view which gives us a lot of
21 de-normalised, but very useful information about packages which have
22 been published in a distribution."""
23
24 id = Attribute("The id of the packagepublishing record")
25 archive = Attribute("The archive where the package is published.")
26 distribution = Attribute("The distribution id")
27 distroarchseries = Attribute("The distroarchseries.")
28 distroseries = Attribute("The distribution series id")
29 distroseriesname = Attribute("The distribution series name")
30 processorfamily = Attribute("The processor family id")
31 processorfamilyname = Attribute("The processor family name")
32 packagepublishingstatus = Attribute("The status of this published package")
33 component = Attribute("The component in which the package has been published")
34 section = Attribute("The section in which it is published.")
35 binarypackagerelease = Attribute("The id of the binary package in question")
36 binarypackagename = Attribute("The binary package name")
37 binarypackagesummary = Attribute("The binary package summary")
38 binarypackagedescription = Attribute("The binary package description")
39 binarypackageversion = Attribute("The binary package version")
40 build = Attribute("The build id")
41 datebuilt = Attribute("The date this package was built or uploaded")
42 sourcepackagerelease = Attribute("Source package release id")
43 sourcepackagereleaseversion = Attribute("Source package release version")
44 sourcepackagename = Attribute("Source package name")
45
46
47class IPublishedPackageSet(Interface):
48 """The set of packages that are published across all distributions"""
49
50 def __iter__():
51 """Iterate over all published packages."""
52
53 def query(name=None, text=None, distribution=None, distroseries=None,
54 distroarchseries=None, component=None):
55 """Search through published packages returning those that meet the
56 given criteria"""
57
58 def findDepCandidate(name, distroarchseries):
59 """Return the package candidate within the distroarchseries context.
60
61 Return the PublishedPackage record by bynarypackagename or None if
62 not found.
63 """
640
=== 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 22:12:56 +0000
@@ -147,15 +147,6 @@
147 distinct=True)147 distinct=True)
148148
149 @property149 @property
150 def meta_binaries(self):
151 """See `IDistroSeriesSourcePackageRelease`."""
152 binary_pkg_names = sorted(
153 set([pkg.binarypackagename for pkg in self.binaries]),
154 key=attrgetter('name'))
155 return [self.distroseries.getBinaryPackage(name)
156 for name in binary_pkg_names]
157
158 @property
159 def changesfile(self):150 def changesfile(self):
160 """See `IDistroSeriesSourcePackageRelease`."""151 """See `IDistroSeriesSourcePackageRelease`."""
161 return self.sourcepackagerelease.upload_changesfile152 return self.sourcepackagerelease.upload_changesfile
162153
=== 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 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# pylint: disable-msg=E0611,W0212
5
6__metaclass__ = type
7__all__ = ['PublishedPackage', 'PublishedPackageSet']
8
9from zope.interface import implements
10
11from sqlobject import StringCol, ForeignKey
12
13from canonical.database.sqlbase import SQLBase, quote, quote_like
14from canonical.database.datetimecol import UtcDateTimeCol
15from canonical.database.enumcol import EnumCol
16
17from lp.soyuz.interfaces.publishedpackage import (
18 IPublishedPackage, IPublishedPackageSet)
19from lp.soyuz.interfaces.publishing import PackagePublishingStatus
20
21
22class PublishedPackage(SQLBase):
23 """See IPublishedPackage for details."""
24
25 implements(IPublishedPackage)
26
27 _table = 'PublishedPackage'
28
29 archive = ForeignKey(
30 dbName='archive', foreignKey='Archive', immutable=True)
31 distribution = ForeignKey(dbName='distribution',
32 foreignKey='Distribution',
33 immutable=True)
34 distroarchseries = ForeignKey(dbName='distroarchseries',
35 foreignKey='DistroArchSeries',
36 immutable=True)
37 distroseries = ForeignKey(dbName='distroseries',
38 foreignKey='DistroSeries',
39 immutable=True)
40 distroseriesname = StringCol(dbName='distroseriesname', immutable=True)
41 processorfamily = ForeignKey(dbName="processorfamily",
42 foreignKey="ProcessorFamily",
43 immutable=True)
44 processorfamilyname = StringCol(immutable=True)
45 packagepublishingstatus = EnumCol(immutable=True,
46 schema=PackagePublishingStatus)
47 component = StringCol(immutable=True)
48 section = StringCol(immutable=True)
49 binarypackagerelease = ForeignKey(dbName="binarypackagerelease",
50 foreignKey="BinaryPackageRelease",
51 immutable=True)
52 binarypackagename = StringCol(immutable=True)
53 binarypackagesummary = StringCol(immutable=True)
54 binarypackagedescription = StringCol(immutable=True)
55 binarypackageversion = StringCol(immutable=True)
56 build = ForeignKey(foreignKey='BinaryPackageBuild', dbName='build')
57 datebuilt = UtcDateTimeCol(immutable=True)
58 sourcepackagerelease = ForeignKey(dbName="sourcepackagerelease",
59 foreignKey="SourcePackageRelease",
60 immutable=True)
61 sourcepackagereleaseversion = StringCol(immutable=True)
62 sourcepackagename = StringCol(immutable=True)
63
64
65class PublishedPackageSet:
66
67 implements(IPublishedPackageSet)
68
69 def __iter__(self):
70 return iter(PublishedPackage.select())
71
72 def query(self, name=None, text=None, distribution=None,
73 distroseries=None, distroarchseries=None, component=None):
74 queries = []
75 if name:
76 name = name.lower().strip().split()[0]
77 queries.append("binarypackagename ILIKE '%%' || %s || '%%'"
78 % quote_like(name))
79 if distribution:
80 queries.append("distribution = %d" % distribution.id)
81 if distroseries:
82 queries.append("distroseries = %d" % distroseries.id)
83 if distroarchseries:
84 queries.append("distroarchseries = %d" % distroarchseries.id)
85 if component:
86 queries.append("component = %s" % quote(component))
87 if text:
88 text = text.lower().strip()
89 queries.append("binarypackagefti @@ ftq(%s)" % quote(text))
90 return PublishedPackage.select(
91 " AND ".join(queries), orderBy=['-datebuilt',])
92
93 def findDepCandidate(self, name, distroarchseries):
94 """See IPublishedSet."""
95 return PublishedPackage.selectOneBy(binarypackagename=name,
96 distroarchseries=distroarchseries)

Subscribers

People subscribed via source and target branches

to status/vote changes: