~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/packageset.py

  • Committer: Danilo Segan
  • Date: 2011-04-22 14:02:29 UTC
  • mto: This revision was merged to the branch mainline in revision 12910.
  • Revision ID: danilo@canonical.com-20110422140229-zhq4d4c2k8jpglhf
Ignore hidden files when building combined JS file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
17
17
from zope.component import getUtility
18
18
from zope.interface import implements
19
19
 
 
20
from canonical.launchpad.helpers import ensure_unicode
 
21
from canonical.launchpad.interfaces.lpstorm import (
 
22
    IMasterStore,
 
23
    IStore,
 
24
    )
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 (
24
29
    ISourcePackageNameSet,
25
30
    )
26
31
from lp.registry.model.sourcepackagename import SourcePackageName
27
 
from lp.services.database.lpstorm import (
28
 
    IMasterStore,
29
 
    IStore,
30
 
    )
31
 
from lp.services.helpers import ensure_unicode
32
32
from lp.soyuz.interfaces.packageset import (
33
33
    DuplicatePackagesetName,
34
34
    IPackageset,
36
36
    NoSuchPackageSet,
37
37
    )
38
38
from lp.soyuz.model.packagesetgroup import PackagesetGroup
39
 
from lp.soyuz.model.packagesetsources import PackagesetSources
40
39
 
41
40
 
42
41
def _order_result_set(result_set):
428
427
            source_name = getUtility(ISourcePackageNameSet)[source_name]
429
428
        return source_name
430
429
 
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
443
 
 
444
430
    def setsIncludingSource(self, sourcepackagename, distroseries=None,
445
431
                            direct_inclusion=False):
446
432
        """See `IPackagesetSet`."""
447
433
        sourcepackagename = self._nameToSourcePackageName(sourcepackagename)
448
434
 
449
 
        if direct_inclusion:
450
 
            query = '''
451
 
                SELECT pss.packageset FROM packagesetsources pss
452
 
                WHERE pss.sourcepackagename = ?
453
 
            '''
454
 
        else:
 
435
        if direct_inclusion == False:
455
436
            query = '''
456
437
                SELECT fpsi.parent
457
438
                FROM packagesetsources pss, flatpackagesetinclusion fpsi
458
439
                WHERE pss.sourcepackagename = ?
459
440
                AND pss.packageset = fpsi.child
460
441
            '''
 
442
        else:
 
443
            query = '''
 
444
                SELECT pss.packageset FROM packagesetsources pss
 
445
                WHERE pss.sourcepackagename = ?
 
446
            '''
461
447
        store = IStore(Packageset)
462
448
        psets = SQL(query, (sourcepackagename.id,))
463
449
        clauses = [Packageset.id.is_in(psets)]