~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/distroseries.py

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    )
39
39
from zope.component import getUtility
40
40
from zope.interface import implements
41
 
from zope.security.interfaces import Unauthorized
42
41
from zope.security.proxy import removeSecurityProxy
43
42
 
44
43
from canonical.database.constants import (
99
98
    IDistroSeries,
100
99
    IDistroSeriesSet,
101
100
    )
 
101
from lp.registry.interfaces.distroseriesdifference import (
 
102
    IDistroSeriesDifferenceSource,
 
103
    )
102
104
from lp.registry.interfaces.person import validate_public_person
103
105
from lp.registry.interfaces.pocket import (
104
106
    PackagePublishingPocket,
750
752
            clauseTables=['SourcePackageRelease',
751
753
                          'SourcePackagePublishingHistory']).count()
752
754
 
753
 
 
754
755
        # next update the binary count
755
756
        clauseTables = ['DistroArchSeries', 'BinaryPackagePublishingHistory',
756
757
                        'BinaryPackageRelease']
787
788
    @property
788
789
    def is_derived_series(self):
789
790
        """See `IDistroSeries`."""
790
 
        # XXX rvb 2011-04-11 bug=754750: This should be cleaned up once
791
 
        # the bug is fixed.
792
 
        return self.previous_series is not None
 
791
        return not self.getParentSeries() == []
793
792
 
794
793
    @property
795
794
    def is_initialising(self):
2005
2004
        getUtility(IInitialiseDistroSeriesJobSource).create(
2006
2005
            self, parents, architectures, packagesets, rebuild)
2007
2006
 
 
2007
    def getParentSeries(self):
 
2008
        """See `IDistroSeriesPublic`."""
 
2009
        # Circular imports.
 
2010
        from lp.registry.interfaces.distroseriesparent import (
 
2011
            IDistroSeriesParentSet,
 
2012
            )
 
2013
        dsps = getUtility(IDistroSeriesParentSet).getByDerivedSeries(self)
 
2014
        return [dsp.parent_series for dsp in dsps]
 
2015
 
2008
2016
    def getDerivedSeries(self):
2009
2017
        """See `IDistroSeriesPublic`."""
2010
 
        # XXX rvb 2011-04-08 bug=754750: The clause
2011
 
        # 'DistroSeries.distributionID!=self.distributionID' is only
2012
 
        # required because the previous_series attribute has been
2013
 
        # (mis-)used to denote other relations than proper derivation
2014
 
        # relashionships. We should be rid of this condition once
2015
 
        # the bug is fixed.
2016
 
        results = Store.of(self).find(
2017
 
            DistroSeries,
2018
 
            DistroSeries.previous_series==self.id,
2019
 
            DistroSeries.distributionID!=self.distributionID)
2020
 
        return results.order_by(Desc(DistroSeries.date_created))
 
2018
        # Circular imports.
 
2019
        from lp.registry.interfaces.distroseriesparent import (
 
2020
            IDistroSeriesParentSet,
 
2021
            )
 
2022
        dsps = getUtility(IDistroSeriesParentSet).getByParentSeries(self)
 
2023
        return [dsp.derived_series for dsp in dsps]
2021
2024
 
2022
2025
    def getBugTaskWeightFunction(self):
2023
2026
        """Provide a weight function to determine optimal bug task.
2039
2042
                return OrderedBugTask(3, bugtask.id, bugtask)
2040
2043
        return weight_function
2041
2044
 
 
2045
    def getDifferencesTo(self, parent_series=None, difference_type=None,
 
2046
                         source_package_name_filter=None, status=None,
 
2047
                         child_version_higher=False):
 
2048
        """See `IDistroSeries`."""
 
2049
        return getUtility(
 
2050
            IDistroSeriesDifferenceSource).getForDistroSeries(
 
2051
                self,
 
2052
                difference_type = difference_type,
 
2053
                source_package_name_filter=source_package_name_filter,
 
2054
                status=status,
 
2055
                child_version_higher=child_version_higher)
 
2056
 
2042
2057
 
2043
2058
class DistroSeriesSet:
2044
2059
    implements(IDistroSeriesSet)