33
33
'DistributionSourcePackageVocabulary',
34
34
'DistributionVocabulary',
35
35
'DistroSeriesDerivationVocabulary',
36
'DistroSeriesDifferencesVocabulary',
36
37
'DistroSeriesVocabulary',
37
38
'FeaturedProjectVocabulary',
38
39
'FilteredDistroSeriesVocabulary',
167
171
from lp.registry.interfaces.sourcepackage import ISourcePackage
168
172
from lp.registry.model.distribution import Distribution
169
173
from lp.registry.model.distroseries import DistroSeries
174
from lp.registry.model.distroseriesdifference import DistroSeriesDifference
170
175
from lp.registry.model.distroseriesparent import DistroSeriesParent
171
176
from lp.registry.model.featuredproject import FeaturedProject
172
177
from lp.registry.model.karma import KarmaCategory
194
199
from lp.soyuz.model.binarypackagename import BinaryPackageName
195
200
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
196
201
from lp.soyuz.model.distroarchseries import DistroArchSeries
197
from lp.soyuz.model.publishing import (
198
SourcePackagePublishingHistory,
202
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
200
203
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
1866
1869
return self.find_terms(where)
1872
class DistroSeriesDifferencesVocabulary:
1873
"""A vocabulary source for differences relating to a series.
1875
Specifically, all `DistroSeriesDifference`s relating to a derived series.
1878
implements(IHugeVocabulary)
1880
displayname = "Choose a difference"
1881
step_title = 'Search'
1883
def __init__(self, context):
1884
"""Create a new vocabulary for the context.
1886
:type context: `IDistroSeries`.
1888
assert IDistroSeries.providedBy(context)
1889
self.distroseries = context
1892
"""See `IIterableVocabulary`."""
1893
return self.searchForDifferences().count()
1896
"""See `IIterableVocabulary`."""
1897
for difference in self.searchForDifferences():
1898
yield self.toTerm(difference)
1900
def __contains__(self, value):
1901
"""See `IVocabulary`."""
1903
IDistroSeriesDifference.providedBy(value) and
1904
value.derived_series == self.distroseries)
1906
def getTerm(self, value):
1907
"""See `IVocabulary`."""
1908
if value not in self:
1909
raise LookupError(value)
1910
return self.toTerm(value)
1912
def getTermByToken(self, token):
1913
"""See `IVocabularyTokenized`."""
1914
if not token.isdigit():
1915
raise LookupError(token)
1916
difference = IStore(DistroSeriesDifference).get(
1917
DistroSeriesDifference, int(token))
1918
if difference is None:
1919
raise LookupError(token)
1920
elif difference.derived_series != self.distroseries:
1921
raise LookupError(token)
1923
return self.toTerm(difference)
1927
"""Return the term for a `DistroSeriesDifference`."""
1928
return SimpleTerm(dsd, dsd.id)
1930
def searchForTerms(self, query=None):
1931
"""See `IHugeVocabulary`."""
1932
results = self.searchForDifferences()
1933
return CountableIterator(results.count(), results, self.toTerm)
1935
def searchForDifferences(self):
1936
"""The set of `DistroSeriesDifference`s related to the context.
1938
:return: `IResultSet` yielding `IDistroSeriesDifference`.
1940
return DistroSeriesDifference.getForDistroSeries(self.distroseries)
1869
1943
class PillarVocabularyBase(NamedSQLObjectHugeVocabulary):
1870
1944
"""Active `IPillar` objects vocabulary."""
1871
1945
displayname = 'Needs to be overridden'