~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/vocabularies.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-15 13:51:32 UTC
  • mfrom: (13444.1.3 dsp-vocab-use-spn)
  • Revision ID: launchpad@pqm.canonical.com-20110715135132-e8nsgc9pkt0p204s
[r=adeuring,
        wallyworld][no-qa] Force the DistributionSourcePackage vocab to
        expect and return SourcePackageNames.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1983
1983
    displayname = 'Select a package'
1984
1984
    step_title = 'Search'
1985
1985
 
1986
 
    def __init__(self, context=None):
 
1986
    def __init__(self, context):
1987
1987
        self.context = context
1988
1988
 
1989
1989
    def __contains__(self, obj):
1995
1995
    def __len__(self):
1996
1996
        pass
1997
1997
 
1998
 
    def toTerm(self, dsp):
 
1998
    def toTerm(self, spn):
1999
1999
        """See `IVocabulary`."""
2000
 
        # SimpleTerm(value, token=None, title=None)
 
2000
        dsp = self.context.getSourcePackage(spn)
2001
2001
        if dsp.publishing_history:
2002
2002
            binaries = dsp.publishing_history[0].getBuiltBinaries()
2003
2003
            summary = ', '.join(
2007
2007
        token = '%s-%s' % (dsp.distribution.name, dsp.name)
2008
2008
        return SimpleTerm(summary, token, dsp.name)
2009
2009
 
2010
 
    def getTerm(self, dsp):
 
2010
    def getTerm(self, spn):
2011
2011
        """See `IBaseVocabulary`."""
2012
 
        return self.toTerm(dsp)
 
2012
        return self.toTerm(spn)
2013
2013
 
2014
2014
    def getTermByToken(self, token):
2015
2015
        """See `IVocabularyTokenized`."""
2059
2059
                    SourcePackageName.name.contains_string(search_term),
2060
2060
                    BinaryPackageName.name.contains_string(
2061
2061
                        search_term))).config(distinct=True)
2062
 
        return [
2063
 
            self.toTerm(distribution.getSourcePackage(spn)) for spn in spns]
 
2062
        return [self.toTerm(spn) for spn in spns]