17
17
from zope.component import getUtility
18
18
from zope.interface import implements
20
from canonical.launchpad.helpers import ensure_unicode
21
from canonical.launchpad.interfaces.lpstorm import (
20
25
from lp.app.errors import NotFoundError
21
26
from lp.registry.interfaces.distribution import IDistributionSet
22
27
from lp.registry.interfaces.sourcepackagename import (
428
427
source_name = getUtility(ISourcePackageNameSet)[source_name]
429
428
return source_name
431
def getForPackages(self, distroseries, sourcepackagename_ids):
432
"""See `IPackagesetSet`."""
433
tuples = IStore(Packageset).find(
434
(PackagesetSources.sourcepackagename_id, Packageset),
435
Packageset.id == PackagesetSources.packageset_id,
436
Packageset.distroseries == distroseries,
437
PackagesetSources.sourcepackagename_id.is_in(
438
sourcepackagename_ids))
439
packagesets_by_package = {}
440
for package, packageset in tuples:
441
packagesets_by_package.setdefault(package, []).append(packageset)
442
return packagesets_by_package
444
430
def setsIncludingSource(self, sourcepackagename, distroseries=None,
445
431
direct_inclusion=False):
446
432
"""See `IPackagesetSet`."""
447
433
sourcepackagename = self._nameToSourcePackageName(sourcepackagename)
451
SELECT pss.packageset FROM packagesetsources pss
452
WHERE pss.sourcepackagename = ?
435
if direct_inclusion == False:
456
437
SELECT fpsi.parent
457
438
FROM packagesetsources pss, flatpackagesetinclusion fpsi
458
439
WHERE pss.sourcepackagename = ?
459
440
AND pss.packageset = fpsi.child
444
SELECT pss.packageset FROM packagesetsources pss
445
WHERE pss.sourcepackagename = ?
461
447
store = IStore(Packageset)
462
448
psets = SQL(query, (sourcepackagename.id,))
463
449
clauses = [Packageset.id.is_in(psets)]