14
14
from lazr.delegates import delegates
15
from operator import itemgetter
16
from storm.expr import (
21
from storm.store import Store
15
22
from zope.interface import implements
16
23
from zope.security.proxy import removeSecurityProxy
18
25
from canonical.database.sqlbase import sqlvalues
26
from canonical.launchpad.components.decoratedresultset import (
19
29
from lp.registry.interfaces.distroseries import IDistroSeries
20
30
from lp.soyuz.enums import PackagePublishingStatus
21
31
from lp.soyuz.interfaces.distroseriessourcepackagerelease import (
22
32
IDistroSeriesSourcePackageRelease,
24
34
from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
35
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
36
from lp.soyuz.model.binarypackagename import BinaryPackageName
25
37
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
26
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
38
from lp.soyuz.model.publishing import (
39
BinaryPackagePublishingHistory,
40
SourcePackagePublishingHistory,
29
44
class DistroSeriesSourcePackageRelease:
123
138
def binaries(self):
124
139
"""See `IDistroSeriesSourcePackageRelease`."""
126
'BinaryPackageRelease',
128
'BinaryPackageBuild',
129
'BinaryPackagePublishingHistory'
133
BinaryPackageRelease.build=BinaryPackageBuild.id AND
134
DistroArchSeries.id =
135
BinaryPackagePublishingHistory.distroarchseries AND
136
BinaryPackagePublishingHistory.binarypackagerelease=
137
BinaryPackageRelease.id AND
138
DistroArchSeries.distroseries=%s AND
139
BinaryPackagePublishingHistory.archive IN %s AND
140
BinaryPackageBuild.source_package_release=%s
141
""" % sqlvalues(self.distroseries,
142
self.distroseries.distribution.all_distro_archive_ids,
143
self.sourcepackagerelease)
145
return BinaryPackageRelease.select(
146
query, prejoinClauseTables=['BinaryPackageBuild'],
147
orderBy=['-id'], clauseTables=clauseTables,
140
# Avoid circular imports.
141
from lp.soyuz.model.distroarchseries import DistroArchSeries
142
store = Store.of(self.distroseries)
144
BinaryPackageRelease, BinaryPackageBuild, BinaryPackageName)
147
BinaryPackageRelease,
150
BinaryPackageBuild.id == BinaryPackageRelease.buildID),
152
BinaryPackagePublishingHistory,
153
BinaryPackageRelease.id ==
154
BinaryPackagePublishingHistory.binarypackagereleaseID),
157
DistroArchSeries.id ==
158
BinaryPackagePublishingHistory.distroarchseriesID),
161
BinaryPackageName.id ==
162
BinaryPackageRelease.binarypackagenameID))
164
self.distroseries.distribution.all_distro_archive_ids)
165
binaries = store.using(*tables).find(
168
DistroArchSeries.distroseriesID == self.distroseries.id,
169
BinaryPackagePublishingHistory.archiveID.is_in(archive_ids),
170
BinaryPackageBuild.source_package_release ==
171
self.sourcepackagerelease))
172
binaries.order_by(Desc(BinaryPackageRelease.id)).config(distinct=True)
173
return DecoratedResultSet(binaries, itemgetter(0))
151
176
def changesfile(self):