launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20598
[Merge] lp:~cjwatson/launchpad/remove-bpn-vocabulary into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/remove-bpn-vocabulary into lp:launchpad with lp:~cjwatson/launchpad/spn-vocabulary-use-dspc as a prerequisite.
Commit message:
Remove unused POTemplate.binarypackagename and BinaryPackageNameVocabulary.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/remove-bpn-vocabulary/+merge/297039
Remove unused POTemplate.binarypackagename and BinaryPackageNameVocabulary.
I spent some time trying to get a cache- and archive-aware version of this working, but couldn't make it fast enough in some cases (e.g. a search for "linux"). In the end I realised that the only user of this vocabulary was itself unused, so it's easier to just delete the lot.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/remove-bpn-vocabulary into lp:launchpad.
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2016-05-04 13:10:17 +0000
+++ lib/lp/soyuz/configure.zcml 2016-06-10 09:41:41 +0000
@@ -239,24 +239,6 @@
<allow
interface="lp.soyuz.interfaces.binarypackagename.IBinaryPackageName"/>
</class>
- <securedutility
- name="BinaryPackageName"
- component="lp.soyuz.model.binarypackagename.BinaryPackageNameVocabulary"
- provides="zope.schema.interfaces.IVocabularyFactory">
- <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
- </securedutility>
-
- <class class="lp.soyuz.model.binarypackagename.BinaryPackageNameVocabulary">
- <allow interface="lp.services.webapp.vocabulary.IHugeVocabulary"/>
- </class>
-
- <!-- BinaryPackagenameIterator -->
-
- <class
- class="lp.soyuz.model.binarypackagename.BinaryPackageNameIterator">
- <allow
- interface="lp.services.webapp.vocabulary.ICountableIterator"/>
- </class>
<!-- BinaryPackageNameSet -->
=== modified file 'lib/lp/soyuz/doc/vocabularies.txt'
--- lib/lp/soyuz/doc/vocabularies.txt 2016-06-10 09:41:41 +0000
+++ lib/lp/soyuz/doc/vocabularies.txt 2016-06-10 09:41:41 +0000
@@ -110,23 +110,6 @@
('linux-source-2.6.15', u'linux-source-2.6.15')]
-BinaryPackageNameVocabulary
-...........................
-
-All the binary packages in Launchpad.
-
- >>> bpn_vocabulary = vocabulary_registry.get(None, 'BinaryPackageName')
- >>> len(bpn_vocabulary)
- 8
-
- >>> bpn_terms = bpn_vocabulary.searchForTerms("mozilla")
- >>> len(bpn_terms)
- 2
- >>> [(term.token, term.title) for term in bpn_terms]
- [('mozilla-firefox', u'iceweasel huh ?'),
- ('mozilla-firefox-data', u'Mozilla Firefox Data is .....')]
-
-
SourcePackageNameVocabulary
...........................
=== modified file 'lib/lp/soyuz/model/binarypackagename.py'
--- lib/lp/soyuz/model/binarypackagename.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/binarypackagename.py 2016-06-10 09:41:41 +0000
@@ -5,9 +5,7 @@
__all__ = [
'BinaryPackageName',
'BinaryPackageNameSet',
- 'BinaryPackageNameVocabulary',
- 'getBinaryPackageDescriptions',
-]
+ ]
from sqlobject import (
SQLObjectNotFound,
@@ -16,25 +14,16 @@
from storm.expr import Join
from storm.store import EmptyResultSet
from zope.interface import implementer
-from zope.schema.vocabulary import SimpleTerm
from lp.app.errors import NotFoundError
from lp.services.database.interfaces import IStore
-from lp.services.database.sqlbase import (
- SQLBase,
- sqlvalues,
- )
+from lp.services.database.sqlbase import SQLBase
from lp.services.helpers import ensure_unicode
-from lp.services.webapp.vocabulary import (
- BatchedCountableIterator,
- NamedSQLObjectHugeVocabulary,
- )
from lp.soyuz.interfaces.binarypackagename import (
IBinaryPackageName,
IBinaryPackageNameSet,
)
from lp.soyuz.interfaces.publishing import active_publishing_status
-from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
@implementer(IBinaryPackageName)
@@ -110,60 +99,3 @@
BinaryPackagePublishingHistory.archiveID.is_in(archive_ids),
BinaryPackagePublishingHistory.binarypackagenameID.is_in(
name_ids)).config(distinct=True)
-
-
-class BinaryPackageNameIterator(BatchedCountableIterator):
- """An iterator for BinaryPackageNameVocabulary.
-
- Builds descriptions based on releases of that binary package name.
- """
-
- def getTermsWithDescriptions(self, results):
- # Prefill the descriptions dictionary with the latest
- # description uploaded for that package name.
- descriptions = getBinaryPackageDescriptions(results)
- return [SimpleTerm(obj, obj.name,
- descriptions.get(obj.name, "Not uploaded"))
- for obj in results]
-
-
-class BinaryPackageNameVocabulary(NamedSQLObjectHugeVocabulary):
- """A vocabulary for searching for binary package names."""
- _table = BinaryPackageName
- _orderBy = 'name'
- displayname = 'Select a Binary Package'
- iterator = BinaryPackageNameIterator
-
-
-def getBinaryPackageDescriptions(results, use_names=False,
- max_title_length=50):
- """Return a dict of descriptions keyed by package name.
-
- See sourcepackage.py:getSourcePackageDescriptions, which is analogous.
- """
- if len(list(results)) < 1:
- return {}
- if use_names:
- clause = ("BinaryPackageName.name in %s" %
- sqlvalues([pn.name for pn in results]))
- else:
- clause = ("BinaryPackageName.id in %s" %
- sqlvalues([bpn.id for bpn in results]))
-
- descriptions = {}
- releases = BinaryPackageRelease.select(
- """BinaryPackageRelease.binarypackagename =
- BinaryPackageName.id AND
- %s""" % clause,
- clauseTables=["BinaryPackageRelease", "BinaryPackageName"],
- orderBy=["-BinaryPackageRelease.datecreated"])
-
- for release in releases:
- binarypackagename = release.binarypackagename.name
- if binarypackagename not in descriptions:
- description = release.description.strip().replace("\n", " ")
- if len(description) > max_title_length:
- description = (release.description[:max_title_length]
- + "...")
- descriptions[binarypackagename] = description
- return descriptions
=== modified file 'lib/lp/soyuz/tests/test_binarypackagename.py'
--- lib/lp/soyuz/tests/test_binarypackagename.py 2016-02-05 16:51:12 +0000
+++ lib/lp/soyuz/tests/test_binarypackagename.py 2016-06-10 09:41:41 +0000
@@ -5,15 +5,11 @@
__metaclass__ = type
-from datetime import datetime
-
-import pytz
from zope.component import getUtility
from lp.app.errors import NotFoundError
from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
-from lp.soyuz.model.binarypackagename import getBinaryPackageDescriptions
from lp.testing import TestCaseWithFactory
from lp.testing.layers import DatabaseFunctionalLayer
@@ -141,66 +137,3 @@
list(self.name_set.getNotNewByNames(
[name.id for name in names], distroarchseries.distroseries,
[archive.id for archive in archives[:1]])))
-
- def test_getBinaryPackageDescriptions_none(self):
- self.assertEqual({}, getBinaryPackageDescriptions([]))
-
- def test_getBinaryPackageDescriptions_no_release(self):
- name = self.factory.makeBinaryPackageName()
- self.assertEqual({}, getBinaryPackageDescriptions([name]))
-
- def test_getBinaryPackageDescriptions_one_release(self):
- name = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="foo")
- self.assertEqual(
- {name.name: "foo"},
- getBinaryPackageDescriptions([name], max_title_length=3))
-
- def test_getBinaryPackageDescriptions_shortens_names(self):
- name = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="foot")
- self.assertEqual(
- {name.name: "foo..."},
- getBinaryPackageDescriptions([name], max_title_length=3))
-
- def test_getBinaryPackageDescriptions_uses_latest(self):
- name = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="foo",
- date_created=datetime(1980, 1, 1, tzinfo=pytz.UTC))
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="bar",
- date_created=datetime(2000, 1, 1, tzinfo=pytz.UTC))
- self.assertEqual(
- {name.name: "bar"},
- getBinaryPackageDescriptions([name], max_title_length=3))
-
- def test_getBinaryPackageDescriptions_two_packages(self):
- name1 = self.factory.makeBinaryPackageName()
- name2 = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name1, description="foo")
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name2, description="bar")
- self.assertEqual(
- {name1.name: "foo", name2.name: "bar"},
- getBinaryPackageDescriptions([name1, name2], max_title_length=3))
-
- def test_getBinaryPackageDescriptions_strips_newlines(self):
- name = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="f\no")
- self.assertEqual(
- {name.name: "f o"},
- getBinaryPackageDescriptions([name], max_title_length=3))
-
- def test_getBinaryPackageDescriptions_use_names(self):
- name = self.factory.makeBinaryPackageName()
- self.factory.makeBinaryPackageRelease(
- binarypackagename=name, description="foo")
- self.assertEqual(
- {name.name: "foo"},
- getBinaryPackageDescriptions(
- [name], use_names=True, max_title_length=3))
=== modified file 'lib/lp/translations/browser/potemplate.py'
--- lib/lp/translations/browser/potemplate.py 2015-07-08 16:05:11 +0000
+++ lib/lp/translations/browser/potemplate.py 2016-06-10 09:41:41 +0000
@@ -653,7 +653,7 @@
field_names = [
'name', 'translation_domain', 'description', 'header', 'iscurrent',
'owner', 'productseries', 'distroseries', 'sourcepackagename',
- 'from_sourcepackagename', 'sourcepackageversion', 'binarypackagename',
+ 'from_sourcepackagename', 'sourcepackageversion',
'languagepack', 'path', 'source_file_format', 'priority',
'date_last_updated']
label = 'Administer translation template'
=== modified file 'lib/lp/translations/configure.zcml'
--- lib/lp/translations/configure.zcml 2014-11-24 06:20:03 +0000
+++ lib/lp/translations/configure.zcml 2016-06-10 09:41:41 +0000
@@ -394,7 +394,7 @@
permission="launchpad.Admin"
set_attributes="
productseries distroseries
- sourcepackageversion binarypackagename
+ sourcepackageversion
source_file_format source_file date_last_updated
from_sourcepackagename header"/>
</class>
=== modified file 'lib/lp/translations/interfaces/potemplate.py'
--- lib/lp/translations/interfaces/potemplate.py 2015-10-14 16:23:18 +0000
+++ lib/lp/translations/interfaces/potemplate.py 2016-06-10 09:41:41 +0000
@@ -150,14 +150,6 @@
title=_("Source Package Version"),
required=False)
- binarypackagename = Choice(
- title=_("Binary Package"),
- description=_(
- "The package in which this template's translations are "
- "installed."),
- required=False,
- vocabulary="BinaryPackageName")
-
languagepack = exported(Bool(
title=_("Include translations for this template in language packs?"),
description=_(
=== modified file 'lib/lp/translations/model/potemplate.py'
--- lib/lp/translations/model/potemplate.py 2015-07-08 16:05:11 +0000
+++ lib/lp/translations/model/potemplate.py 2016-06-10 09:41:41 +0000
@@ -231,8 +231,6 @@
distroseries = ForeignKey(foreignKey='DistroSeries',
dbName='distroseries', notNull=False, default=None)
header = StringCol(dbName='header', notNull=True)
- binarypackagename = ForeignKey(foreignKey='BinaryPackageName',
- dbName='binarypackagename', notNull=False, default=None)
languagepack = BoolCol(dbName='languagepack', notNull=True, default=False)
date_last_updated = UtcDateTimeCol(dbName='date_last_updated',
default=DEFAULT)
=== modified file 'lib/lp/translations/stories/standalone/xx-potemplate-admin.txt'
--- lib/lp/translations/stories/standalone/xx-potemplate-admin.txt 2016-06-10 09:41:41 +0000
+++ lib/lp/translations/stories/standalone/xx-potemplate-admin.txt 2016-06-10 09:41:41 +0000
@@ -59,8 +59,6 @@
''
>>> browser.getControl(name='field.sourcepackageversion').value
''
- >>> browser.getControl(name='field.binarypackagename').value
- ''
>>> browser.getControl(name='field.languagepack').value
False
>>> browser.getControl(name='field.path').value
@@ -107,8 +105,6 @@
''
>>> admin_browser.getControl(name='field.sourcepackageversion').value
''
- >>> admin_browser.getControl(name='field.binarypackagename').value
- ''
>>> admin_browser.getControl(name='field.languagepack').value
False
>>> admin_browser.getControl(name='field.path').value
=== modified file 'lib/lp/translations/stories/standalone/xx-potemplate-edit.txt'
--- lib/lp/translations/stories/standalone/xx-potemplate-edit.txt 2011-08-25 19:48:19 +0000
+++ lib/lp/translations/stories/standalone/xx-potemplate-edit.txt 2016-06-10 09:41:41 +0000
@@ -73,11 +73,6 @@
...
LookupError:...
- >>> browser.getControl(name='field.binarypackagename').value
- Traceback (most recent call last):
- ...
- LookupError:...
-
>>> browser.getControl(name='field.languagepack').value
Traceback (most recent call last):
...
Follow ups