131
131
SQLObjectVocabularyBase,
132
132
VocabularyFilter,
134
from canonical.lazr.utils import safe_hasattr
134
135
from lp.app.browser.tales import DateTimeFormatterAPI
135
136
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
136
137
from lp.blueprints.interfaces.specification import ISpecification
173
174
from lp.registry.interfaces.productseries import IProductSeries
174
175
from lp.registry.interfaces.projectgroup import IProjectGroup
175
176
from lp.registry.interfaces.sourcepackage import ISourcePackage
177
from lp.registry.interfaces.sourcepackagename import ISourcePackageName
176
178
from lp.registry.model.distribution import Distribution
179
from lp.registry.model.distributionsourcepackage import (
180
DistributionSourcePackageInDatabase,
177
182
from lp.registry.model.distroseries import DistroSeries
178
183
from lp.registry.model.distroseriesdifference import DistroSeriesDifference
179
184
from lp.registry.model.distroseriesparent import DistroSeriesParent
2231
2236
if IDistributionSourcePackage.providedBy(spn_or_dsp):
2232
2237
dsp = spn_or_dsp
2233
2238
distribution = spn_or_dsp.distribution
2239
elif (not ISourcePackageName.providedBy(spn_or_dsp) and
2240
safe_hasattr(spn_or_dsp, 'distribution')
2241
and safe_hasattr(spn_or_dsp, 'sourcepackagename')):
2242
# We use the hasattr checks rather than adaption because the
2243
# DistributionSourcePackageInDatabase object is a little bit
2244
# broken, and does not provide any interface.
2245
distribution = spn_or_dsp.distribution
2246
dsp = distribution.getSourcePackage(spn_or_dsp.sourcepackagename)
2235
2248
distribution = distribution or self.distribution
2236
2249
if distribution is not None and spn_or_dsp is not None:
2237
2250
dsp = distribution.getSourcePackage(spn_or_dsp)
2239
2252
token = '%s/%s' % (dsp.distribution.name, dsp.name)
2240
binaries = dsp.publishing_history[0].getBuiltBinaries()
2241
binary_names = [binary.binary_package_name for binary in binaries]
2242
if binary_names != []:
2243
summary = ', '.join(binary_names)
2245
summary = 'Not yet built.'
2246
summary = token + ' ' + summary
2247
return SimpleTerm(dsp.sourcepackagename, token, summary)
2253
summary = '%s (%s)' % (token, dsp.name)
2255
# We try to get the binaries for the dsp; if this fails, we return
2256
# lookup error instead.
2257
dsp.publishing_history[0].getBuiltBinaries()
2258
return SimpleTerm(dsp, token, summary)
2259
#return SimpleTerm(dsp, token, summary)
2248
2260
except (IndexError, AttributeError):
2249
2261
# Either the DSP was None or there is no publishing history.
2250
2262
raise LookupError(distribution, spn_or_dsp)
2281
2293
SourcePackageRelease.sourcepackagenameID ==
2282
2294
SourcePackageName.id),
2285
SourcePackagePublishingHistory.distroseriesID ==
2296
DistributionSourcePackageInDatabase,
2297
SourcePackageName.id ==
2298
DistributionSourcePackageInDatabase.sourcepackagename_id),
2288
2300
BinaryPackageBuild,
2289
2301
BinaryPackageBuild.source_package_release_id ==
2296
2308
BinaryPackageRelease.binarypackagenameID ==
2297
2309
BinaryPackageName.id
2300
DistroSeries.distributionID == distribution.id,
2311
DistributionSourcePackageInDatabase,
2312
DistributionSourcePackageInDatabase.distribution_id ==
2301
2314
SourcePackagePublishingHistory.status.is_in((
2302
2315
PackagePublishingStatus.PENDING,
2303
2316
PackagePublishingStatus.PUBLISHED)),
2308
2321
BinaryPackageName.name.contains_string(
2309
2322
search_term))).config(distinct=True)
2310
2323
# XXX sinzui 2011-07-26: This query ignored SPN branches.
2311
return CountableIterator(spns.count(), spns, self.toTerm)
2324
return CountableIterator(dsps.count(), dsps, self.toTerm)