Merge ~cjwatson/launchpad:stormify-translations-queries into launchpad:master
- Git
- lp:~cjwatson/launchpad
- stormify-translations-queries
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | fe326b3b9c807e9d722aa179cf1c9036a4bc43b6 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:stormify-translations-queries |
Merge into: | launchpad:master |
Prerequisite: | ~cjwatson/launchpad:stormify-potranslation |
Diff against target: |
639 lines (+131/-117) 18 files modified
lib/lp/registry/model/distroseries.py (+3/-1) lib/lp/translations/doc/poexport-request-productseries.txt (+9/-10) lib/lp/translations/doc/poexport-request.txt (+4/-2) lib/lp/translations/doc/pofile.txt (+2/-4) lib/lp/translations/doc/potmsgset.txt (+4/-10) lib/lp/translations/doc/translationmessage-destroy.txt (+5/-4) lib/lp/translations/doc/translationrelicensingagreement.txt (+7/-3) lib/lp/translations/interfaces/translationmessage.py (+0/-11) lib/lp/translations/model/pofiletranslator.py (+31/-15) lib/lp/translations/model/potemplate.py (+6/-5) lib/lp/translations/model/translationgroup.py (+12/-9) lib/lp/translations/model/translationmessage.py (+0/-4) lib/lp/translations/model/translationsperson.py (+12/-11) lib/lp/translations/scripts/fix_plural_forms.py (+8/-9) lib/lp/translations/scripts/gettext_check_messages.py (+8/-6) lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt (+5/-5) lib/lp/translations/stories/standalone/xx-potemplate-admin.txt (+4/-2) lib/lp/translations/stories/standalone/xx-translation-access-display.txt (+11/-6) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+395062@code.launchpad.net |
Commit message
Convert SQLObject-style queries in lp.translations to Storm
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py | |||
2 | index 2811a42..e83a7dc 100644 | |||
3 | --- a/lib/lp/registry/model/distroseries.py | |||
4 | +++ b/lib/lp/registry/model/distroseries.py | |||
5 | @@ -178,7 +178,6 @@ from lp.translations.model.hastranslationtemplates import ( | |||
6 | 178 | ) | 178 | ) |
7 | 179 | from lp.translations.model.languagepack import LanguagePack | 179 | from lp.translations.model.languagepack import LanguagePack |
8 | 180 | from lp.translations.model.pofile import POFile | 180 | from lp.translations.model.pofile import POFile |
9 | 181 | from lp.translations.model.pofiletranslator import POFileTranslator | ||
10 | 182 | from lp.translations.model.potemplate import ( | 181 | from lp.translations.model.potemplate import ( |
11 | 183 | POTemplate, | 182 | POTemplate, |
12 | 184 | TranslationTemplatesCollection, | 183 | TranslationTemplatesCollection, |
13 | @@ -1362,6 +1361,9 @@ class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin, | |||
14 | 1362 | 1361 | ||
15 | 1363 | def getPOFileContributorsByLanguage(self, language): | 1362 | def getPOFileContributorsByLanguage(self, language): |
16 | 1364 | """See `IDistroSeries`.""" | 1363 | """See `IDistroSeries`.""" |
17 | 1364 | # Circular import. | ||
18 | 1365 | from lp.translations.model.pofiletranslator import POFileTranslator | ||
19 | 1366 | |||
20 | 1365 | contributors = IStore(Person).find( | 1367 | contributors = IStore(Person).find( |
21 | 1366 | Person, | 1368 | Person, |
22 | 1367 | POFileTranslator.personID == Person.id, | 1369 | POFileTranslator.personID == Person.id, |
23 | diff --git a/lib/lp/translations/doc/poexport-request-productseries.txt b/lib/lp/translations/doc/poexport-request-productseries.txt | |||
24 | index 1978e3e..53303a2 100644 | |||
25 | --- a/lib/lp/translations/doc/poexport-request-productseries.txt | |||
26 | +++ b/lib/lp/translations/doc/poexport-request-productseries.txt | |||
27 | @@ -7,9 +7,9 @@ | |||
28 | 7 | 7 | ||
29 | 8 | This is a dummy logger class to capture the export's log messages. | 8 | This is a dummy logger class to capture the export's log messages. |
30 | 9 | 9 | ||
32 | 10 | >>> from lp.registry.model.person import Person | 10 | >>> from lp.registry.interfaces.person import IPersonSet |
33 | 11 | >>> from lp.services.log.logger import FakeLogger | 11 | >>> from lp.services.log.logger import FakeLogger |
35 | 12 | >>> person = Person.selectOneBy(name='name12') | 12 | >>> person = getUtility(IPersonSet).getByName('name12') |
36 | 13 | 13 | ||
37 | 14 | An arbitrary logged-in user requests an export of all translations for | 14 | An arbitrary logged-in user requests an export of all translations for |
38 | 15 | Evolution series trunk. | 15 | Evolution series trunk. |
39 | @@ -18,16 +18,15 @@ At the UI level, this is easy. At the level we are looking at now, this | |||
40 | 18 | consists of a series of requests for all templates and translations attached | 18 | consists of a series of requests for all templates and translations attached |
41 | 19 | to the product series. | 19 | to the product series. |
42 | 20 | 20 | ||
50 | 21 | >>> from lp.registry.model.product import Product | 21 | >>> from lp.registry.interfaces.product import IProductSet |
51 | 22 | >>> from lp.registry.model.productseries import ProductSeries | 22 | >>> from lp.translations.interfaces.potemplate import IPOTemplateSet |
52 | 23 | >>> from lp.translations.model.potemplate import POTemplate | 23 | >>> evolution_product = getUtility(IProductSet).getByName('evolution') |
53 | 24 | >>> evolution_product = Product.selectOneBy(name='evolution') | 24 | >>> evolution_trunk = evolution_product.getSeries('trunk') |
54 | 25 | >>> evolution_trunk = ProductSeries.selectOneBy( | 25 | >>> potemplates = list(getUtility(IPOTemplateSet).getSubset( |
55 | 26 | ... product=evolution_product, name='trunk') | 26 | ... productseries=evolution_trunk)) |
49 | 27 | >>> potemplates = list(POTemplate.selectBy(productseries=evolution_trunk)) | ||
56 | 28 | >>> pofiles = [] | 27 | >>> pofiles = [] |
57 | 29 | >>> for template in potemplates: | 28 | >>> for template in potemplates: |
59 | 30 | ... pofiles += template.pofiles | 29 | ... pofiles.extend(template.pofiles) |
60 | 31 | 30 | ||
61 | 32 | >>> request_set = getUtility(IPOExportRequestSet) | 31 | >>> request_set = getUtility(IPOExportRequestSet) |
62 | 33 | >>> request_set.addRequest(person, potemplates, pofiles) | 32 | >>> request_set.addRequest(person, potemplates, pofiles) |
63 | diff --git a/lib/lp/translations/doc/poexport-request.txt b/lib/lp/translations/doc/poexport-request.txt | |||
64 | index cf6d13f..8e87314 100644 | |||
65 | --- a/lib/lp/translations/doc/poexport-request.txt | |||
66 | +++ b/lib/lp/translations/doc/poexport-request.txt | |||
67 | @@ -233,9 +233,11 @@ just PO files. | |||
68 | 233 | >>> product_template.productseries is None | 233 | >>> product_template.productseries is None |
69 | 234 | False | 234 | False |
70 | 235 | >>> request_set.addRequest(person, product_template) | 235 | >>> request_set.addRequest(person, product_template) |
72 | 236 | >>> alsa_template = POTemplate.selectOneBy(path='po/alsa-utils.pot') | 236 | >>> alsa_template = IStore(POTemplate).find( |
73 | 237 | ... POTemplate, path='po/alsa-utils.pot').one() | ||
74 | 237 | >>> alsa_es = alsa_template.getPOFileByLang('es') | 238 | >>> alsa_es = alsa_template.getPOFileByLang('es') |
76 | 238 | >>> netapplet_template = POTemplate.selectOneBy(path='po/netapplet.pot') | 239 | >>> netapplet_template = IStore(POTemplate).find( |
77 | 240 | ... POTemplate, path='po/netapplet.pot').one() | ||
78 | 239 | >>> request_set.addRequest( | 241 | >>> request_set.addRequest( |
79 | 240 | ... person, [alsa_template, netapplet_template], [alsa_es]) | 242 | ... person, [alsa_template, netapplet_template], [alsa_es]) |
80 | 241 | >>> transaction.commit() | 243 | >>> transaction.commit() |
81 | diff --git a/lib/lp/translations/doc/pofile.txt b/lib/lp/translations/doc/pofile.txt | |||
82 | index 9caf91d..286080b 100644 | |||
83 | --- a/lib/lp/translations/doc/pofile.txt | |||
84 | +++ b/lib/lp/translations/doc/pofile.txt | |||
85 | @@ -611,10 +611,8 @@ If you have a distroseries and want to know all the people who | |||
86 | 611 | contributed translations on a given language for that distroseries, you | 611 | contributed translations on a given language for that distroseries, you |
87 | 612 | can use the getPOFileContributorsByLanguage() method of IDistroSeries. | 612 | can use the getPOFileContributorsByLanguage() method of IDistroSeries. |
88 | 613 | 613 | ||
93 | 614 | >>> from lp.registry.model.distroseries import DistroSeries | 614 | >>> hoary = distribution.getSeries("hoary") |
94 | 615 | >>> from lp.services.worlddata.model.language import Language | 615 | >>> spanish = getUtility(ILanguageSet)["es"] |
91 | 616 | >>> hoary = DistroSeries.selectOneBy(name="hoary") | ||
92 | 617 | >>> spanish = Language.selectOneBy(code="es") | ||
95 | 618 | >>> print_names(hoary.getPOFileContributorsByLanguage(spanish)) | 616 | >>> print_names(hoary.getPOFileContributorsByLanguage(spanish)) |
96 | 619 | jorge-gonzalez-gonzalez | 617 | jorge-gonzalez-gonzalez |
97 | 620 | carlos | 618 | carlos |
98 | diff --git a/lib/lp/translations/doc/potmsgset.txt b/lib/lp/translations/doc/potmsgset.txt | |||
99 | index ade9470..d07038c 100644 | |||
100 | --- a/lib/lp/translations/doc/potmsgset.txt | |||
101 | +++ b/lib/lp/translations/doc/potmsgset.txt | |||
102 | @@ -612,20 +612,14 @@ POTMsgSet.setSequence | |||
103 | 612 | Finally, the new `IPOTMsgSet` should have an entry in the | 612 | Finally, the new `IPOTMsgSet` should have an entry in the |
104 | 613 | `TranslationTemplateItem` table once we assign a sequence number. | 613 | `TranslationTemplateItem` table once we assign a sequence number. |
105 | 614 | 614 | ||
106 | 615 | >>> from lp.translations.model.translationtemplateitem import ( | ||
107 | 616 | ... TranslationTemplateItem) | ||
108 | 617 | |||
109 | 618 | First, we need a helper function to check whether the potmsgset exists | 615 | First, we need a helper function to check whether the potmsgset exists |
110 | 619 | in the table or not. | 616 | in the table or not. |
111 | 620 | 617 | ||
112 | 621 | |||
113 | 622 | >>> def is_potmsgset_in_potemplate(potmsgset, potemplate): | 618 | >>> def is_potmsgset_in_potemplate(potmsgset, potemplate): |
120 | 623 | ... items = [ | 619 | ... items = { |
121 | 624 | ... item.potmsgset.id | 620 | ... potmsgset.id |
122 | 625 | ... for item in TranslationTemplateItem.selectBy( | 621 | ... for potmsgset in potemplate.getPOTMsgSets(prefetch=False) |
123 | 626 | ... potemplate=potemplate, potmsgset=potmsgset) | 622 | ... } |
118 | 627 | ... if item.sequence > 0 | ||
119 | 628 | ... ] | ||
124 | 629 | ... return potmsgset.id in items | 623 | ... return potmsgset.id in items |
125 | 630 | 624 | ||
126 | 631 | Let's create a new potmsgset object. | 625 | Let's create a new potmsgset object. |
127 | diff --git a/lib/lp/translations/doc/translationmessage-destroy.txt b/lib/lp/translations/doc/translationmessage-destroy.txt | |||
128 | index 8b52fcf..6709859 100644 | |||
129 | --- a/lib/lp/translations/doc/translationmessage-destroy.txt | |||
130 | +++ b/lib/lp/translations/doc/translationmessage-destroy.txt | |||
131 | @@ -36,7 +36,7 @@ translation, we get two POFileTranslator records for each of the POFiles. | |||
132 | 36 | # We need to be able to create persons and projects so let's just use | 36 | # We need to be able to create persons and projects so let's just use |
133 | 37 | # a global 'postgres' permission which allows everything. | 37 | # a global 'postgres' permission which allows everything. |
134 | 38 | >>> switch_dbuser('postgres') | 38 | >>> switch_dbuser('postgres') |
136 | 39 | >>> from lp.services.database.sqlbase import sqlvalues | 39 | >>> from lp.services.database.interfaces import IStore |
137 | 40 | >>> from lp.app.enums import ServiceUsage | 40 | >>> from lp.app.enums import ServiceUsage |
138 | 41 | >>> from lp.testing.factory import LaunchpadObjectFactory | 41 | >>> from lp.testing.factory import LaunchpadObjectFactory |
139 | 42 | >>> from lp.translations.model.pofiletranslator import POFileTranslator | 42 | >>> from lp.translations.model.pofiletranslator import POFileTranslator |
140 | @@ -62,7 +62,8 @@ translation, we get two POFileTranslator records for each of the POFiles. | |||
141 | 62 | ... pofile=devel_sr_pofile, | 62 | ... pofile=devel_sr_pofile, |
142 | 63 | ... potmsgset=potmsgset, | 63 | ... potmsgset=potmsgset, |
143 | 64 | ... translations=[u"blah"]) | 64 | ... translations=[u"blah"]) |
147 | 65 | >>> print(POFileTranslator.select( | 65 | >>> print(IStore(POFileTranslator).find( |
148 | 66 | ... "pofile IN (%s, %s)" | 66 | ... POFileTranslator, |
149 | 67 | ... % sqlvalues(devel_sr_pofile, stable_sr_pofile)).count()) | 67 | ... POFileTranslator.pofileID.is_in( |
150 | 68 | ... (devel_sr_pofile.id, stable_sr_pofile.id))).count()) | ||
151 | 68 | 2 | 69 | 2 |
152 | diff --git a/lib/lp/translations/doc/translationrelicensingagreement.txt b/lib/lp/translations/doc/translationrelicensingagreement.txt | |||
153 | index ad6156d..c40f41b 100644 | |||
154 | --- a/lib/lp/translations/doc/translationrelicensingagreement.txt | |||
155 | +++ b/lib/lp/translations/doc/translationrelicensingagreement.txt | |||
156 | @@ -5,6 +5,7 @@ Launchpad can decide whether they want their translations relicensed | |||
157 | 5 | under BSD or not. | 5 | under BSD or not. |
158 | 6 | 6 | ||
159 | 7 | >>> from zope.component import getUtility | 7 | >>> from zope.component import getUtility |
160 | 8 | >>> from lp.services.database.interfaces import IStore | ||
161 | 8 | >>> from lp.testing import verifyObject | 9 | >>> from lp.testing import verifyObject |
162 | 9 | >>> from lp.translations.model.translationrelicensingagreement \ | 10 | >>> from lp.translations.model.translationrelicensingagreement \ |
163 | 10 | ... import TranslationRelicensingAgreement | 11 | ... import TranslationRelicensingAgreement |
164 | @@ -23,7 +24,8 @@ When Karl has not made his selection yet, it is marked as None. | |||
165 | 23 | 24 | ||
166 | 24 | >>> print(translations_person.translations_relicensing_agreement) | 25 | >>> print(translations_person.translations_relicensing_agreement) |
167 | 25 | None | 26 | None |
169 | 26 | >>> choice = TranslationRelicensingAgreement.selectOneBy(person=person) | 27 | >>> choice = IStore(TranslationRelicensingAgreement).find( |
170 | 28 | ... TranslationRelicensingAgreement, person=person).one() | ||
171 | 27 | >>> print(choice) | 29 | >>> print(choice) |
172 | 28 | None | 30 | None |
173 | 29 | 31 | ||
174 | @@ -33,7 +35,8 @@ object. | |||
175 | 33 | >>> translations_person.translations_relicensing_agreement = True | 35 | >>> translations_person.translations_relicensing_agreement = True |
176 | 34 | >>> print(translations_person.translations_relicensing_agreement) | 36 | >>> print(translations_person.translations_relicensing_agreement) |
177 | 35 | True | 37 | True |
179 | 36 | >>> choice = TranslationRelicensingAgreement.selectOneBy(person=person) | 38 | >>> choice = IStore(TranslationRelicensingAgreement).find( |
180 | 39 | ... TranslationRelicensingAgreement, person=person).one() | ||
181 | 37 | >>> print(choice.allow_relicensing) | 40 | >>> print(choice.allow_relicensing) |
182 | 38 | True | 41 | True |
183 | 39 | 42 | ||
184 | @@ -47,6 +50,7 @@ A translator can also change their mind later. | |||
185 | 47 | >>> translations_person.translations_relicensing_agreement = False | 50 | >>> translations_person.translations_relicensing_agreement = False |
186 | 48 | >>> print(translations_person.translations_relicensing_agreement) | 51 | >>> print(translations_person.translations_relicensing_agreement) |
187 | 49 | False | 52 | False |
189 | 50 | >>> choice = TranslationRelicensingAgreement.selectOneBy(person=person) | 53 | >>> choice = IStore(TranslationRelicensingAgreement).find( |
190 | 54 | ... TranslationRelicensingAgreement, person=person).one() | ||
191 | 51 | >>> print(choice.allow_relicensing) | 55 | >>> print(choice.allow_relicensing) |
192 | 52 | False | 56 | False |
193 | diff --git a/lib/lp/translations/interfaces/translationmessage.py b/lib/lp/translations/interfaces/translationmessage.py | |||
194 | index f06c9e6..5b66292 100644 | |||
195 | --- a/lib/lp/translations/interfaces/translationmessage.py | |||
196 | +++ b/lib/lp/translations/interfaces/translationmessage.py | |||
197 | @@ -333,17 +333,6 @@ class ITranslationMessageSet(Interface): | |||
198 | 333 | def getByID(id): | 333 | def getByID(id): |
199 | 334 | """Return the TranslationMessage with the given ID or None.""" | 334 | """Return the TranslationMessage with the given ID or None.""" |
200 | 335 | 335 | ||
201 | 336 | def selectDirect(where=None, order_by=None): | ||
202 | 337 | """Return sequence of `TranslationMessage`s matching arguments. | ||
203 | 338 | |||
204 | 339 | This is meant for maintenance use. If you find yourself using | ||
205 | 340 | it anywhere except in a manually-run script, try something else. | ||
206 | 341 | |||
207 | 342 | :param where: An SQL WHERE clause describing which messages to | ||
208 | 343 | return. | ||
209 | 344 | :param order_by: An SQL ORDER BY clause. | ||
210 | 345 | """ | ||
211 | 346 | |||
212 | 347 | def preloadDetails(messages, pofile=None, need_pofile=False, | 336 | def preloadDetails(messages, pofile=None, need_pofile=False, |
213 | 348 | need_potemplate=False, need_potemplate_context=False, | 337 | need_potemplate=False, need_potemplate_context=False, |
214 | 349 | need_potranslation=False, need_potmsgset=False, | 338 | need_potranslation=False, need_potmsgset=False, |
215 | diff --git a/lib/lp/translations/model/pofiletranslator.py b/lib/lp/translations/model/pofiletranslator.py | |||
216 | index 3f1bf02..a8ea10a 100644 | |||
217 | --- a/lib/lp/translations/model/pofiletranslator.py | |||
218 | +++ b/lib/lp/translations/model/pofiletranslator.py | |||
219 | @@ -7,23 +7,32 @@ __all__ = [ | |||
220 | 7 | 'POFileTranslatorSet', | 7 | 'POFileTranslatorSet', |
221 | 8 | ] | 8 | ] |
222 | 9 | 9 | ||
223 | 10 | from operator import itemgetter | ||
224 | 10 | 11 | ||
225 | 11 | from sqlobject import ForeignKey | 12 | from sqlobject import ForeignKey |
227 | 12 | from storm.expr import And | 13 | from storm.expr import ( |
228 | 14 | And, | ||
229 | 15 | Join, | ||
230 | 16 | LeftJoin, | ||
231 | 17 | ) | ||
232 | 13 | from storm.store import Store | 18 | from storm.store import Store |
233 | 14 | from zope.interface import implementer | 19 | from zope.interface import implementer |
234 | 15 | 20 | ||
235 | 16 | from lp.registry.interfaces.person import validate_public_person | 21 | from lp.registry.interfaces.person import validate_public_person |
236 | 22 | from lp.registry.model.distroseries import DistroSeries | ||
237 | 23 | from lp.registry.model.product import Product | ||
238 | 24 | from lp.registry.model.productseries import ProductSeries | ||
239 | 25 | from lp.registry.model.sourcepackagename import SourcePackageName | ||
240 | 17 | from lp.services.database.datetimecol import UtcDateTimeCol | 26 | from lp.services.database.datetimecol import UtcDateTimeCol |
245 | 18 | from lp.services.database.sqlbase import ( | 27 | from lp.services.database.decoratedresultset import DecoratedResultSet |
246 | 19 | SQLBase, | 28 | from lp.services.database.interfaces import IStore |
247 | 20 | sqlvalues, | 29 | from lp.services.database.sqlbase import SQLBase |
244 | 21 | ) | ||
248 | 22 | from lp.translations.interfaces.pofiletranslator import ( | 30 | from lp.translations.interfaces.pofiletranslator import ( |
249 | 23 | IPOFileTranslator, | 31 | IPOFileTranslator, |
250 | 24 | IPOFileTranslatorSet, | 32 | IPOFileTranslatorSet, |
251 | 25 | ) | 33 | ) |
252 | 26 | from lp.translations.model.pofile import POFile | 34 | from lp.translations.model.pofile import POFile |
253 | 35 | from lp.translations.model.potemplate import POTemplate | ||
254 | 27 | 36 | ||
255 | 28 | 37 | ||
256 | 29 | @implementer(IPOFileTranslator) | 38 | @implementer(IPOFileTranslator) |
257 | @@ -47,17 +56,24 @@ class POFileTranslatorSet: | |||
258 | 47 | if not ids: | 56 | if not ids: |
259 | 48 | return None | 57 | return None |
260 | 49 | 58 | ||
261 | 59 | origin = [ | ||
262 | 60 | POFileTranslator, | ||
263 | 61 | Join(POFile, POFileTranslator.pofile == POFile.id), | ||
264 | 62 | Join(POTemplate, POFile.potemplate == POTemplate.id), | ||
265 | 63 | LeftJoin( | ||
266 | 64 | ProductSeries, POTemplate.productseries == ProductSeries.id), | ||
267 | 65 | LeftJoin(Product, ProductSeries.product == Product.id), | ||
268 | 66 | LeftJoin(DistroSeries, POTemplate.distroseries == DistroSeries.id), | ||
269 | 67 | LeftJoin( | ||
270 | 68 | SourcePackageName, | ||
271 | 69 | POTemplate.sourcepackagename == SourcePackageName.id), | ||
272 | 70 | ] | ||
273 | 71 | rows = IStore(POFileTranslator).using(*origin).find( | ||
274 | 72 | (POFileTranslator, POFile, POTemplate, | ||
275 | 73 | ProductSeries, Product, DistroSeries, SourcePackageName), | ||
276 | 74 | POFileTranslator.id.is_in(ids)) | ||
277 | 50 | # Listify prefetch query to force its execution here. | 75 | # Listify prefetch query to force its execution here. |
288 | 51 | return list(POFileTranslator.select( | 76 | return list(DecoratedResultSet(rows, itemgetter(0))) |
279 | 52 | "POFileTranslator.id IN %s" % sqlvalues(ids), | ||
280 | 53 | prejoins=[ | ||
281 | 54 | 'pofile', | ||
282 | 55 | 'pofile.potemplate', | ||
283 | 56 | 'pofile.potemplate.productseries', | ||
284 | 57 | 'pofile.potemplate.productseries.product', | ||
285 | 58 | 'pofile.potemplate.distroseries', | ||
286 | 59 | 'pofile.potemplate.sourcepackagename', | ||
287 | 60 | ])) | ||
289 | 61 | 77 | ||
290 | 62 | def getForPersonPOFile(self, person, pofile): | 78 | def getForPersonPOFile(self, person, pofile): |
291 | 63 | """See `IPOFileTranslatorSet`.""" | 79 | """See `IPOFileTranslatorSet`.""" |
292 | diff --git a/lib/lp/translations/model/potemplate.py b/lib/lp/translations/model/potemplate.py | |||
293 | index b0b5e2a..ebdbc42 100644 | |||
294 | --- a/lib/lp/translations/model/potemplate.py | |||
295 | +++ b/lib/lp/translations/model/potemplate.py | |||
296 | @@ -542,7 +542,7 @@ class POTemplate(SQLBase, RosettaStats): | |||
297 | 542 | 542 | ||
298 | 543 | def getPOFileByPath(self, path): | 543 | def getPOFileByPath(self, path): |
299 | 544 | """See `IPOTemplate`.""" | 544 | """See `IPOTemplate`.""" |
301 | 545 | return POFile.selectOneBy(potemplate=self, path=path) | 545 | return IStore(POFile).find(POFile, potemplate=self, path=path).one() |
302 | 546 | 546 | ||
303 | 547 | def getPOFileByLang(self, language_code): | 547 | def getPOFileByLang(self, language_code): |
304 | 548 | """See `IPOTemplate`.""" | 548 | """See `IPOTemplate`.""" |
305 | @@ -1281,17 +1281,18 @@ class POTemplateSet: | |||
306 | 1281 | 1281 | ||
307 | 1282 | def __iter__(self): | 1282 | def __iter__(self): |
308 | 1283 | """See `IPOTemplateSet`.""" | 1283 | """See `IPOTemplateSet`.""" |
311 | 1284 | res = POTemplate.select() | 1284 | for potemplate in IStore(POTemplate).find(POTemplate): |
310 | 1285 | for potemplate in res: | ||
312 | 1286 | yield potemplate | 1285 | yield potemplate |
313 | 1287 | 1286 | ||
314 | 1288 | def getAllByName(self, name): | 1287 | def getAllByName(self, name): |
315 | 1289 | """See `IPOTemplateSet`.""" | 1288 | """See `IPOTemplateSet`.""" |
317 | 1290 | return POTemplate.selectBy(name=name, orderBy=['name', 'id']) | 1289 | return IStore(POTemplate).find(POTemplate, name=name).order_by( |
318 | 1290 | POTemplate.name, POTemplate.id) | ||
319 | 1291 | 1291 | ||
320 | 1292 | def getAllOrderByDateLastUpdated(self): | 1292 | def getAllOrderByDateLastUpdated(self): |
321 | 1293 | """See `IPOTemplateSet`.""" | 1293 | """See `IPOTemplateSet`.""" |
323 | 1294 | return POTemplate.select(orderBy=['-date_last_updated']) | 1294 | return IStore(POTemplate).find(POTemplate).order_by( |
324 | 1295 | Desc(POTemplate.date_last_updated)) | ||
325 | 1295 | 1296 | ||
326 | 1296 | def getSubset(self, distroseries=None, sourcepackagename=None, | 1297 | def getSubset(self, distroseries=None, sourcepackagename=None, |
327 | 1297 | productseries=None, iscurrent=None, | 1298 | productseries=None, iscurrent=None, |
328 | diff --git a/lib/lp/translations/model/translationgroup.py b/lib/lp/translations/model/translationgroup.py | |||
329 | index 994172d..80267ba 100644 | |||
330 | --- a/lib/lp/translations/model/translationgroup.py | |||
331 | +++ b/lib/lp/translations/model/translationgroup.py | |||
332 | @@ -17,6 +17,7 @@ from sqlobject import ( | |||
333 | 17 | StringCol, | 17 | StringCol, |
334 | 18 | ) | 18 | ) |
335 | 19 | from storm.expr import ( | 19 | from storm.expr import ( |
336 | 20 | Desc, | ||
337 | 20 | Join, | 21 | Join, |
338 | 21 | LeftJoin, | 22 | LeftJoin, |
339 | 22 | ) | 23 | ) |
340 | @@ -100,8 +101,8 @@ class TranslationGroup(SQLBase): | |||
341 | 100 | # get a translator by language or code | 101 | # get a translator by language or code |
342 | 101 | def query_translator(self, language): | 102 | def query_translator(self, language): |
343 | 102 | """See ITranslationGroup.""" | 103 | """See ITranslationGroup.""" |
346 | 103 | return Translator.selectOneBy(language=language, | 104 | return IStore(Translator).find( |
347 | 104 | translationgroup=self) | 105 | Translator, language=language, translationgroup=self).one() |
348 | 105 | 106 | ||
349 | 106 | @property | 107 | @property |
350 | 107 | def products(self): | 108 | def products(self): |
351 | @@ -109,7 +110,8 @@ class TranslationGroup(SQLBase): | |||
352 | 109 | # Avoid circular imports. | 110 | # Avoid circular imports. |
353 | 110 | from lp.registry.model.product import Product | 111 | from lp.registry.model.product import Product |
354 | 111 | 112 | ||
356 | 112 | return Product.selectBy(translationgroup=self.id, active=True) | 113 | return IStore(Product).find( |
357 | 114 | Product, translationgroup=self, active=True) | ||
358 | 113 | 115 | ||
359 | 114 | @property | 116 | @property |
360 | 115 | def projects(self): | 117 | def projects(self): |
361 | @@ -117,7 +119,8 @@ class TranslationGroup(SQLBase): | |||
362 | 117 | # Avoid circular imports. | 119 | # Avoid circular imports. |
363 | 118 | from lp.registry.model.projectgroup import ProjectGroup | 120 | from lp.registry.model.projectgroup import ProjectGroup |
364 | 119 | 121 | ||
366 | 120 | return ProjectGroup.selectBy(translationgroup=self.id, active=True) | 122 | return IStore(ProjectGroup).find( |
367 | 123 | ProjectGroup, translationgroup=self, active=True) | ||
368 | 121 | 124 | ||
369 | 122 | # A limit of projects to get for the `top_projects`. | 125 | # A limit of projects to get for the `top_projects`. |
370 | 123 | TOP_PROJECTS_LIMIT = 6 | 126 | TOP_PROJECTS_LIMIT = 6 |
371 | @@ -260,10 +263,10 @@ class TranslationGroupSet: | |||
372 | 260 | # group names from their respective celebrities. For now, | 263 | # group names from their respective celebrities. For now, |
373 | 261 | # just hard-code them so they show up at the top of the | 264 | # just hard-code them so they show up at the top of the |
374 | 262 | # listing of all translation groups. | 265 | # listing of all translation groups. |
379 | 263 | for group in TranslationGroup.select( | 266 | for group in IStore(TranslationGroup).find(TranslationGroup).order_by( |
380 | 264 | orderBy=[ | 267 | Desc(TranslationGroup.name.is_in(( |
381 | 265 | "-(name in ('launchpad-translators', 'ubuntu-translators'))", | 268 | 'launchpad-translators', 'ubuntu-translators'))), |
382 | 266 | "title"]): | 269 | TranslationGroup.title): |
383 | 267 | yield group | 270 | yield group |
384 | 268 | 271 | ||
385 | 269 | def __getitem__(self, name): | 272 | def __getitem__(self, name): |
386 | @@ -306,4 +309,4 @@ class TranslationGroupSet: | |||
387 | 306 | 309 | ||
388 | 307 | def getGroupsCount(self): | 310 | def getGroupsCount(self): |
389 | 308 | """See ITranslationGroupSet.""" | 311 | """See ITranslationGroupSet.""" |
391 | 309 | return TranslationGroup.select().count() | 312 | return IStore(TranslationGroup).find(TranslationGroup).count() |
392 | diff --git a/lib/lp/translations/model/translationmessage.py b/lib/lp/translations/model/translationmessage.py | |||
393 | index b323a20..cdbdca6 100644 | |||
394 | --- a/lib/lp/translations/model/translationmessage.py | |||
395 | +++ b/lib/lp/translations/model/translationmessage.py | |||
396 | @@ -546,10 +546,6 @@ class TranslationMessageSet: | |||
397 | 546 | except SQLObjectNotFound: | 546 | except SQLObjectNotFound: |
398 | 547 | return None | 547 | return None |
399 | 548 | 548 | ||
400 | 549 | def selectDirect(self, where=None, order_by=None): | ||
401 | 550 | """See `ITranslationMessageSet`.""" | ||
402 | 551 | return TranslationMessage.select(where, orderBy=order_by) | ||
403 | 552 | |||
404 | 553 | def preloadDetails(self, messages, pofile=None, need_pofile=False, | 549 | def preloadDetails(self, messages, pofile=None, need_pofile=False, |
405 | 554 | need_potemplate=False, need_potemplate_context=False, | 550 | need_potemplate=False, need_potemplate_context=False, |
406 | 555 | need_potranslation=False, need_potmsgset=False, | 551 | need_potranslation=False, need_potmsgset=False, |
407 | diff --git a/lib/lp/translations/model/translationsperson.py b/lib/lp/translations/model/translationsperson.py | |||
408 | index 0fa28d9..6c28d7b 100644 | |||
409 | --- a/lib/lp/translations/model/translationsperson.py | |||
410 | +++ b/lib/lp/translations/model/translationsperson.py | |||
411 | @@ -30,11 +30,12 @@ from lp.app.interfaces.launchpad import ILaunchpadCelebrities | |||
412 | 30 | from lp.registry.interfaces.person import IPerson | 30 | from lp.registry.interfaces.person import IPerson |
413 | 31 | from lp.registry.model.distribution import Distribution | 31 | from lp.registry.model.distribution import Distribution |
414 | 32 | from lp.registry.model.distroseries import DistroSeries | 32 | from lp.registry.model.distroseries import DistroSeries |
415 | 33 | from lp.registry.model.person import PersonLanguage | ||
416 | 33 | from lp.registry.model.product import Product | 34 | from lp.registry.model.product import Product |
417 | 34 | from lp.registry.model.productseries import ProductSeries | 35 | from lp.registry.model.productseries import ProductSeries |
418 | 35 | from lp.registry.model.projectgroup import ProjectGroup | 36 | from lp.registry.model.projectgroup import ProjectGroup |
419 | 36 | from lp.registry.model.teammembership import TeamParticipation | 37 | from lp.registry.model.teammembership import TeamParticipation |
421 | 37 | from lp.services.database.sqlbase import sqlvalues | 38 | from lp.services.database.interfaces import IStore |
422 | 38 | from lp.services.propertycache import ( | 39 | from lp.services.propertycache import ( |
423 | 39 | cachedproperty, | 40 | cachedproperty, |
424 | 40 | get_property_cache, | 41 | get_property_cache, |
425 | @@ -64,12 +65,12 @@ class TranslationsPerson: | |||
426 | 64 | @property | 65 | @property |
427 | 65 | def translatable_languages(self): | 66 | def translatable_languages(self): |
428 | 66 | """See `ITranslationsPerson`.""" | 67 | """See `ITranslationsPerson`.""" |
435 | 67 | return Language.select(""" | 68 | return IStore(Language).find( |
436 | 68 | Language.id = PersonLanguage.language AND | 69 | Language, |
437 | 69 | PersonLanguage.person = %s AND | 70 | PersonLanguage.language == Language.id, |
438 | 70 | Language.code <> 'en' AND | 71 | PersonLanguage.person == self.person, |
439 | 71 | Language.visible""" % sqlvalues(self.person), | 72 | Language.code != 'en', |
440 | 72 | clauseTables=['PersonLanguage'], orderBy='englishname') | 73 | Language.visible).order_by(Language.englishname) |
441 | 73 | 74 | ||
442 | 74 | def getTranslationHistory(self, no_older_than=None): | 75 | def getTranslationHistory(self, no_older_than=None): |
443 | 75 | """See `ITranslationsPerson`.""" | 76 | """See `ITranslationsPerson`.""" |
444 | @@ -108,8 +109,8 @@ class TranslationsPerson: | |||
445 | 108 | 109 | ||
446 | 109 | If they have made no explicit decision yet, return None. | 110 | If they have made no explicit decision yet, return None. |
447 | 110 | """ | 111 | """ |
450 | 111 | relicensing_agreement = TranslationRelicensingAgreement.selectOneBy( | 112 | relicensing_agreement = IStore(TranslationRelicensingAgreement).find( |
451 | 112 | person=self.person) | 113 | TranslationRelicensingAgreement, person=self.person).one() |
452 | 113 | if relicensing_agreement is None: | 114 | if relicensing_agreement is None: |
453 | 114 | return None | 115 | return None |
454 | 115 | else: | 116 | else: |
455 | @@ -123,8 +124,8 @@ class TranslationsPerson: | |||
456 | 123 | 124 | ||
457 | 124 | If they have already made a decision, overrides it with the new one. | 125 | If they have already made a decision, overrides it with the new one. |
458 | 125 | """ | 126 | """ |
461 | 126 | relicensing_agreement = TranslationRelicensingAgreement.selectOneBy( | 127 | relicensing_agreement = IStore(TranslationRelicensingAgreement).find( |
462 | 127 | person=self.person) | 128 | TranslationRelicensingAgreement, person=self.person).one() |
463 | 128 | if relicensing_agreement is None: | 129 | if relicensing_agreement is None: |
464 | 129 | relicensing_agreement = TranslationRelicensingAgreement( | 130 | relicensing_agreement = TranslationRelicensingAgreement( |
465 | 130 | person=self.person, | 131 | person=self.person, |
466 | diff --git a/lib/lp/translations/scripts/fix_plural_forms.py b/lib/lp/translations/scripts/fix_plural_forms.py | |||
467 | index 8d264ae..df8e25c 100644 | |||
468 | --- a/lib/lp/translations/scripts/fix_plural_forms.py | |||
469 | +++ b/lib/lp/translations/scripts/fix_plural_forms.py | |||
470 | @@ -11,12 +11,11 @@ __all__ = [ | |||
471 | 11 | 11 | ||
472 | 12 | from sqlobject import SQLObjectNotFound | 12 | from sqlobject import SQLObjectNotFound |
473 | 13 | 13 | ||
478 | 14 | from lp.services.database.sqlbase import ( | 14 | from lp.services.database.interfaces import IStore |
479 | 15 | cursor, | 15 | from lp.services.database.sqlbase import cursor |
476 | 16 | sqlvalues, | ||
477 | 17 | ) | ||
480 | 18 | from lp.translations.interfaces.translations import TranslationConstants | 16 | from lp.translations.interfaces.translations import TranslationConstants |
481 | 19 | from lp.translations.model.pofile import POFile | 17 | from lp.translations.model.pofile import POFile |
482 | 18 | from lp.translations.model.potmsgset import POTMsgSet | ||
483 | 20 | from lp.translations.model.translationmessage import TranslationMessage | 19 | from lp.translations.model.translationmessage import TranslationMessage |
484 | 21 | from lp.translations.utilities.gettext_po_parser import POHeader | 20 | from lp.translations.utilities.gettext_po_parser import POHeader |
485 | 22 | from lp.translations.utilities.pluralforms import plural_form_mapper | 21 | from lp.translations.utilities.pluralforms import plural_form_mapper |
486 | @@ -49,11 +48,11 @@ def fix_pofile_plurals(pofile, logger, ztm): | |||
487 | 49 | plural_forms_mapping = get_mapping_for_pofile_plurals(pofile) | 48 | plural_forms_mapping = get_mapping_for_pofile_plurals(pofile) |
488 | 50 | if plural_forms_mapping is not None: | 49 | if plural_forms_mapping is not None: |
489 | 51 | logger.info("Fixing PO file %s" % pofile.title) | 50 | logger.info("Fixing PO file %s" % pofile.title) |
495 | 52 | pluralmessages = TranslationMessage.select(""" | 51 | pluralmessages = IStore(TranslationMessage).find( |
496 | 53 | POTMsgSet.id = TranslationMessage.potmsgset AND | 52 | TranslationMessage, |
497 | 54 | POTMsgSet.msgid_plural IS NOT NULL AND | 53 | TranslationMessage.potmsgset == POTMsgSet.id, |
498 | 55 | TranslationMessage.pofile = %s""" % sqlvalues(pofile), | 54 | POTMsgSet.msgid_plural != None, |
499 | 56 | clauseTables=["POTMsgSet"]) | 55 | TranslationMessage.pofile == pofile) |
500 | 57 | for message in pluralmessages: | 56 | for message in pluralmessages: |
501 | 58 | logger.debug("\tFixing translations for '%s'" % ( | 57 | logger.debug("\tFixing translations for '%s'" % ( |
502 | 59 | message.potmsgset.singular_text)) | 58 | message.potmsgset.singular_text)) |
503 | diff --git a/lib/lp/translations/scripts/gettext_check_messages.py b/lib/lp/translations/scripts/gettext_check_messages.py | |||
504 | index fa6a388..b4e4345 100644 | |||
505 | --- a/lib/lp/translations/scripts/gettext_check_messages.py | |||
506 | +++ b/lib/lp/translations/scripts/gettext_check_messages.py | |||
507 | @@ -11,13 +11,12 @@ from datetime import ( | |||
508 | 11 | ) | 11 | ) |
509 | 12 | 12 | ||
510 | 13 | import six | 13 | import six |
512 | 14 | from zope.component import getUtility | 14 | from storm.locals import SQL |
513 | 15 | from zope.security.proxy import removeSecurityProxy | 15 | from zope.security.proxy import removeSecurityProxy |
514 | 16 | 16 | ||
515 | 17 | from lp.services.database.interfaces import IStore | ||
516 | 17 | from lp.services.scripts.base import LaunchpadScript | 18 | from lp.services.scripts.base import LaunchpadScript |
520 | 18 | from lp.translations.interfaces.translationmessage import ( | 19 | from lp.translations.model.translationmessage import TranslationMessage |
518 | 19 | ITranslationMessageSet, | ||
519 | 20 | ) | ||
521 | 21 | from lp.translations.utilities.validate import ( | 20 | from lp.translations.utilities.validate import ( |
522 | 22 | GettextValidationError, | 21 | GettextValidationError, |
523 | 23 | validate_translation, | 22 | validate_translation, |
524 | @@ -66,8 +65,11 @@ class GettextCheckMessages(LaunchpadScript): | |||
525 | 66 | self.logger.debug( | 65 | self.logger.debug( |
526 | 67 | "Checking messages matching: %s" % self.options.where) | 66 | "Checking messages matching: %s" % self.options.where) |
527 | 68 | 67 | ||
530 | 69 | messages = getUtility(ITranslationMessageSet).selectDirect( | 68 | messages = IStore(TranslationMessage).find(TranslationMessage) |
531 | 70 | self.options.where, order_by=self.options.order_by) | 69 | if self.options.where is not None: |
532 | 70 | messages = messages.find(SQL(self.options.where)) | ||
533 | 71 | if self.options.order_by is not None: | ||
534 | 72 | messages = messages.order_by(SQL(self.options.order_by)) | ||
535 | 71 | self._iterate(messages) | 73 | self._iterate(messages) |
536 | 72 | 74 | ||
537 | 73 | self.logger.info("Done.") | 75 | self.logger.info("Done.") |
538 | diff --git a/lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt b/lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt | |||
539 | index 8e9f427..9c15385 100644 | |||
540 | --- a/lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt | |||
541 | +++ b/lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt | |||
542 | @@ -294,12 +294,13 @@ Ubuntu uploads | |||
543 | 294 | As a special case, the owners of Ubuntu's translation group are allowed | 294 | As a special case, the owners of Ubuntu's translation group are allowed |
544 | 295 | to manage Ubuntu uploads. | 295 | to manage Ubuntu uploads. |
545 | 296 | 296 | ||
547 | 297 | >>> from lp.registry.model.distribution import Distribution | 297 | >>> from zope.component import getUtility |
548 | 298 | >>> from lp.registry.interfaces.distribution import IDistributionSet | ||
549 | 298 | >>> from lp.translations.model.translationimportqueue import ( | 299 | >>> from lp.translations.model.translationimportqueue import ( |
550 | 299 | ... TranslationImportQueue) | 300 | ... TranslationImportQueue) |
551 | 300 | >>> login('admin@canonical.com') | 301 | >>> login('admin@canonical.com') |
552 | 301 | >>> queue = TranslationImportQueue() | 302 | >>> queue = TranslationImportQueue() |
554 | 302 | >>> ubuntu = Distribution.selectOneBy(name='ubuntu') | 303 | >>> ubuntu = getUtility(IDistributionSet)['ubuntu'] |
555 | 303 | >>> hoary = ubuntu['hoary'] | 304 | >>> hoary = ubuntu['hoary'] |
556 | 304 | 305 | ||
557 | 305 | There is a translation group for Ubuntu. Its owner has no special | 306 | There is a translation group for Ubuntu. Its owner has no special |
558 | @@ -307,17 +308,16 @@ privileges or roles other than running the group. | |||
559 | 307 | 308 | ||
560 | 308 | Somebody else has uploaded a translation template for an Ubuntu package. | 309 | Somebody else has uploaded a translation template for an Ubuntu package. |
561 | 309 | 310 | ||
562 | 310 | >>> login(ANONYMOUS) | ||
563 | 311 | |||
564 | 312 | >>> package = factory.makeSourcePackageName() | 311 | >>> package = factory.makeSourcePackageName() |
565 | 313 | >>> group_owner = factory.makePerson( | 312 | >>> group_owner = factory.makePerson( |
566 | 314 | ... email='go@example.com', name='groupowner') | 313 | ... email='go@example.com', name='groupowner') |
567 | 315 | >>> uploader = factory.makePerson() | 314 | >>> uploader = factory.makePerson() |
568 | 316 | >>> ubuntu.translationgroup = factory.makeTranslationGroup(group_owner) | 315 | >>> ubuntu.translationgroup = factory.makeTranslationGroup(group_owner) |
569 | 316 | |||
570 | 317 | >>> login(ANONYMOUS) | ||
571 | 317 | >>> ubuntu_upload = queue.addOrUpdateEntry( | 318 | >>> ubuntu_upload = queue.addOrUpdateEntry( |
572 | 318 | ... 'messages.pot', b'(content)', False, uploader, | 319 | ... 'messages.pot', b'(content)', False, uploader, |
573 | 319 | ... sourcepackagename=package, distroseries=hoary) | 320 | ... sourcepackagename=package, distroseries=hoary) |
574 | 320 | |||
575 | 321 | >>> logout() | 321 | >>> logout() |
576 | 322 | 322 | ||
577 | 323 | The owner of Ubuntu's translation group, despite not being the owner or | 323 | The owner of Ubuntu's translation group, despite not being the owner or |
578 | diff --git a/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt b/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt | |||
579 | index bf9852a..59a9600 100644 | |||
580 | --- a/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt | |||
581 | +++ b/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt | |||
582 | @@ -186,10 +186,11 @@ Distribution templates | |||
583 | 186 | Distributions get slightly wider permissions to manage their templates | 186 | Distributions get slightly wider permissions to manage their templates |
584 | 187 | autonomously. | 187 | autonomously. |
585 | 188 | 188 | ||
587 | 189 | >>> from lp.registry.model.distribution import Distribution | 189 | >>> from zope.component import getUtility |
588 | 190 | >>> from lp.registry.interfaces.distribution import IDistributionSet | ||
589 | 190 | >>> from lp.translations.model.potemplate import POTemplateSet | 191 | >>> from lp.translations.model.potemplate import POTemplateSet |
590 | 191 | >>> login('admin@canonical.com') | 192 | >>> login('admin@canonical.com') |
592 | 192 | >>> ubuntu = Distribution.selectOneBy(name='ubuntu') | 193 | >>> ubuntu = getUtility(IDistributionSet)['ubuntu'] |
593 | 193 | >>> hoary = ubuntu['hoary'] | 194 | >>> hoary = ubuntu['hoary'] |
594 | 194 | >>> templateset = POTemplateSet() | 195 | >>> templateset = POTemplateSet() |
595 | 195 | 196 | ||
596 | @@ -201,6 +202,7 @@ autonomously. | |||
597 | 201 | >>> template = templatesubset.new( | 202 | >>> template = templatesubset.new( |
598 | 202 | ... 'foo', 'foo', 'foo.pot', template_owner) | 203 | ... 'foo', 'foo', 'foo.pot', template_owner) |
599 | 203 | 204 | ||
600 | 205 | >>> login('admin@canonical.com') | ||
601 | 204 | >>> distro_owner = factory.makePerson('do@example.com') | 206 | >>> distro_owner = factory.makePerson('do@example.com') |
602 | 205 | >>> ubuntu.owner = distro_owner | 207 | >>> ubuntu.owner = distro_owner |
603 | 206 | 208 | ||
604 | diff --git a/lib/lp/translations/stories/standalone/xx-translation-access-display.txt b/lib/lp/translations/stories/standalone/xx-translation-access-display.txt | |||
605 | index d374966..adcc0bd 100644 | |||
606 | --- a/lib/lp/translations/stories/standalone/xx-translation-access-display.txt | |||
607 | +++ b/lib/lp/translations/stories/standalone/xx-translation-access-display.txt | |||
608 | @@ -38,20 +38,25 @@ translation group of its own, that too is shown here. | |||
609 | 38 | 38 | ||
610 | 39 | >>> import re | 39 | >>> import re |
611 | 40 | 40 | ||
612 | 41 | >>> from zope.component import getUtility | ||
613 | 42 | >>> from zope.security.proxy import removeSecurityProxy | ||
614 | 43 | |||
615 | 41 | >>> from lp.services.database.constants import UTC_NOW | 44 | >>> from lp.services.database.constants import UTC_NOW |
619 | 42 | >>> from lp.registry.model.person import Person | 45 | >>> from lp.registry.interfaces.person import IPersonSet |
620 | 43 | >>> from lp.registry.model.product import Product | 46 | >>> from lp.registry.interfaces.product import IProductSet |
621 | 44 | >>> from lp.services.worlddata.model.language import Language | 47 | >>> from lp.services.worlddata.interfaces.language import ILanguageSet |
622 | 45 | >>> from lp.translations.model.translationgroup import ( | 48 | >>> from lp.translations.model.translationgroup import ( |
623 | 46 | ... TranslationGroup) | 49 | ... TranslationGroup) |
624 | 47 | 50 | ||
628 | 48 | >>> spanish = Language.selectOneBy(code='es') | 51 | >>> login('admin@canonical.com') |
629 | 49 | >>> evolution = Product.selectOneBy(name='evolution') | 52 | >>> spanish = getUtility(ILanguageSet)['es'] |
630 | 50 | >>> foobar = Person.selectOneBy(name='name16') | 53 | >>> evolution = removeSecurityProxy(getUtility(IProductSet)['evolution']) |
631 | 54 | >>> foobar = getUtility(IPersonSet).getByName('name16') | ||
632 | 51 | >>> gnomegroup = TranslationGroup(name='gnomegroup', | 55 | >>> gnomegroup = TranslationGroup(name='gnomegroup', |
633 | 52 | ... title="Gnome translation group", summary="Testing group", | 56 | ... title="Gnome translation group", summary="Testing group", |
634 | 53 | ... datecreated=UTC_NOW, owner=foobar) | 57 | ... datecreated=UTC_NOW, owner=foobar) |
635 | 54 | >>> evolution.projectgroup.translationgroup = gnomegroup | 58 | >>> evolution.projectgroup.translationgroup = gnomegroup |
636 | 59 | >>> logout() | ||
637 | 55 | 60 | ||
638 | 56 | >>> admin_browser.open( | 61 | >>> admin_browser.open( |
639 | 57 | ... 'http://translations.launchpad.test/' | 62 | ... 'http://translations.launchpad.test/' |
looks good