Merge lp:~jtv/launchpad/bug-668194-fix-api into lp:launchpad

Proposed by Jeroen T. Vermeulen on 2010-10-29
Status: Merged
Approved by: Jeroen T. Vermeulen on 2010-10-29
Approved revision: no longer in the source branch.
Merged at revision: 11829
Proposed branch: lp:~jtv/launchpad/bug-668194-fix-api
Merge into: lp:launchpad
Prerequisite: lp:~jtv/launchpad/bug-668194-split-interfaces
Diff against target: 562 lines (+94/-78)
22 files modified
lib/lp/registry/configure.zcml (+0/-12)
lib/lp/registry/interfaces/distribution.py (+5/-2)
lib/lp/registry/interfaces/distroseries.py (+5/-1)
lib/lp/registry/interfaces/person.py (+4/-1)
lib/lp/registry/interfaces/product.py (+7/-3)
lib/lp/registry/interfaces/productseries.py (+4/-1)
lib/lp/registry/interfaces/sourcepackage.py (+4/-1)
lib/lp/registry/model/distribution.py (+1/-1)
lib/lp/registry/model/distroseries.py (+3/-3)
lib/lp/registry/model/person.py (+1/-1)
lib/lp/registry/model/product.py (+3/-3)
lib/lp/registry/model/productseries.py (+3/-3)
lib/lp/registry/model/sourcepackage.py (+3/-3)
lib/lp/translations/browser/hastranslationimports.py (+3/-2)
lib/lp/translations/interfaces/hastranslationimports.py (+1/-1)
lib/lp/translations/interfaces/webservice.py (+0/-2)
lib/lp/translations/model/approver.py (+4/-4)
lib/lp/translations/model/hastranslationimports.py (+36/-0)
lib/lp/translations/model/pofile.py (+3/-3)
lib/lp/translations/model/translationimportqueue.py (+0/-26)
lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py (+4/-4)
lib/lp/translations/utilities/tests/test_xpi_search.py (+0/-1)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-668194-fix-api
Reviewer Review Type Date Requested Status
Abel Deuring (community) code 2010-10-29 Approve on 2010-10-29
Review via email: mp+39615@code.launchpad.net

Commit Message

Export IHasTranslationImports to the API usably.

Description of the Change

= Bug 668194: IHasTranslationImports in the API =

You may find this bug easier to review one commit at a time. I went through three stages:
 1. Add IHasTranslationTemplates to persons, products etc. through interface inheritance instead of implements().
 2. Move HasTranslationTemplatesMixin to its own module, since I just did the same for the matching interface.
 3. Clean up pre-existing lint, insofar as it affected Translations. Not particularly interesting.

The first step is the crux of this branch. Previously, various classes that have translation import queues associated with them implement IHasTranslationTemplates: Distribution, DistroSeries, Person, Product, ProductSeries, SourcePackage. IHasTranslationTemplates was already exported on the API, but now we're actually exporting one of its methods.

Unfortunately, setting things up this way created a useless new class on the API, corresponding to IHasTranslationImports, with the method in question. It didn't help any of the classes that implement IHasTranslationTemplates. Instead I had to derive their main interfaces from IHasTranslationImports. (In order to avoid circular imports I first had to split off bits of the translations import queue interface module in a separate branch).

The second step is really just there to finish a forgotten piece of the preparatory work. The lint fixes I limited to Translations files because otherwise the diff would get out of hand just like that of the preparatory branch.

Besides the 20th-century-school inheritance setup, two other things are not really to my liking in this branch.

First: I can't test the fix. The current test uses the webservice object to test the presence of the new method, but the webservice object doesn't care about interfaces as specified in the WADL. So it was perfectly happy to call the method and thus prove that it worked, even though launchpadlib won't see it at all. I filed that as bug 668190.

I tried complementing and even re-writing the test to use launchpadlib instead of the webservice object. But the cost was entirely unacceptable—25 seconds or so. The proper place to test this is in the webservice object, not in the tests for each element of the web service API and especially not at such an enormous cost per.

That said, of course I did verify the fix manually and will do so again in Q/A.

Second thing I don't like: IHasTranslationImports ends up being in the API as a totally useless class. I tried not exporting the interface, but that produced an error I did not understand. If anyone ever cares, we can try to remove that later.

To run the test, such as it is (though I actually ran all Translations tests apart from the windmill ones):
{{{
./bin/test -vvc lp.translations.tests -t webservice.xx-translationimportqueue
}}}

Jeroen

To post a comment you must log in.
Abel Deuring (adeuring) :
review: Approve (code)
Abel Deuring (adeuring) wrote :

Hi Henning,

the code changes look overall good, but I am not very happy that we lie to our users. Would it be very difficult to tell people who don't have the permission to view the branch: "yes, there is a branch for synchronization, but sorry, you can't look at it."?

Did you discuss the different options with somebody?

Anyway, if there is an sort of agreement that it is OK to give the somehwat misleading message "no synchronization branch linked", I'll approve the branch. But could you change the doc string for has_import_enabled so that it says that the user permissions are "mixed into" the result value. And could you add such a doc string (or coemment) for has_exports_enabled and uses_bzr_sync?

Otherwise, developers might also be surprised if they use these properties without careful looking ;) (OK, I know that the code documented by the doc string/comment is just two lines below -- but at least I read somehwat selectively and could easily miss the additional clauses...

review: Needs Information
Abel Deuring (adeuring) wrote :

sorry... browser tabs can cause a mess.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/configure.zcml'
2--- lib/lp/registry/configure.zcml 2010-10-29 10:43:52 +0000
3+++ lib/lp/registry/configure.zcml 2010-10-29 10:43:53 +0000
4@@ -156,8 +156,6 @@
5 <allow
6 interface="lp.soyuz.interfaces.queue.IHasQueueItems"/>
7 <allow
8- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
9- <allow
10 interface="lp.soyuz.interfaces.publishing.ICanPublishPackages"/>
11 <require
12 permission="launchpad.Edit"
13@@ -849,8 +847,6 @@
14 <allow
15 interface="lp.registry.interfaces.person.ITeamPublic"/>
16 <allow
17- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
18- <allow
19 interface="lp.registry.interfaces.person.IHasStanding"/>
20 <allow
21 interface="lp.registry.interfaces.person.IPersonCommAdminWriteRestricted"/>
22@@ -1113,8 +1109,6 @@
23 <allow
24 interface="lp.bugs.interfaces.bugtarget.IHasBugHeat"/>
25 <allow
26- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
27- <allow
28 interface="lp.translations.interfaces.customlanguagecode.IHasCustomLanguageCodes"/>
29 <require
30 permission="launchpad.View"
31@@ -1382,8 +1376,6 @@
32 interface="lp.registry.interfaces.productseries.IProductSeriesEditRestricted"/>
33 <allow
34 interface="lp.bugs.interfaces.bugtarget.IHasBugHeat"/>
35- <allow
36- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
37 <require
38 permission="launchpad.Edit"
39 set_schema="lp.app.interfaces.launchpad.IServiceUsage"/>
40@@ -1447,8 +1439,6 @@
41 interface="lp.registry.interfaces.distribution.IDistributionPublic"/>
42 <allow
43 interface="lp.bugs.interfaces.bugtarget.IHasBugHeat"/>
44- <allow
45- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
46 <require
47 permission="launchpad.Edit"
48 interface="lp.registry.interfaces.distribution.IDistributionEditRestricted"/>
49@@ -1595,8 +1585,6 @@
50 interface="lp.bugs.interfaces.bugtarget.IHasBugHeat"/>
51 <allow
52 interface="lp.soyuz.interfaces.buildrecords.IHasBuildRecords"/>
53- <allow
54- interface="lp.translations.interfaces.hastranslationimports.IHasTranslationImports"/>
55
56 <!-- IQuestionTarget -->
57
58
59=== modified file 'lib/lp/registry/interfaces/distribution.py'
60--- lib/lp/registry/interfaces/distribution.py 2010-10-14 17:30:10 +0000
61+++ lib/lp/registry/interfaces/distribution.py 2010-10-29 10:43:53 +0000
62@@ -97,6 +97,9 @@
63 Title,
64 )
65 from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
66+from lp.translations.interfaces.hastranslationimports import (
67+ IHasTranslationImports,
68+ )
69 from lp.translations.interfaces.translationgroup import ITranslationPolicy
70
71
72@@ -128,8 +131,8 @@
73 class IDistributionPublic(
74 IBugTarget, ICanGetMilestonesDirectly, IHasAppointedDriver,
75 IHasBuildRecords, IHasDrivers, IHasMentoringOffers, IHasMilestones,
76- IHasOwner, IHasSecurityContact, IHasSprints, ITranslationPolicy,
77- IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
78+ IHasOwner, IHasSecurityContact, IHasSprints, IHasTranslationImports,
79+ ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
80 IOfficialBugTagTargetPublic, IPillar, IServiceUsage,
81 ISpecificationTarget):
82 """Public IDistribution properties."""
83
84=== modified file 'lib/lp/registry/interfaces/distroseries.py'
85--- lib/lp/registry/interfaces/distroseries.py 2010-10-18 04:19:10 +0000
86+++ lib/lp/registry/interfaces/distroseries.py 2010-10-29 10:43:53 +0000
87@@ -86,6 +86,9 @@
88 UniqueField,
89 )
90 from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
91+from lp.translations.interfaces.hastranslationimports import (
92+ IHasTranslationImports,
93+ )
94 from lp.translations.interfaces.languagepack import ILanguagePack
95 from lp.translations.interfaces.potemplate import IHasTranslationTemplates
96
97@@ -179,7 +182,8 @@
98 class IDistroSeriesPublic(
99 ISeriesMixin, IHasAppointedDriver, IHasOwner, IBugTarget,
100 ISpecificationGoal, IHasMilestones, IHasOfficialBugTags,
101- IHasBuildRecords, IHasTranslationTemplates, IServiceUsage):
102+ IHasBuildRecords, IHasTranslationImports, IHasTranslationTemplates,
103+ IServiceUsage):
104 """Public IDistroSeries properties."""
105
106 id = Attribute("The distroseries's unique number.")
107
108=== modified file 'lib/lp/registry/interfaces/person.py'
109--- lib/lp/registry/interfaces/person.py 2010-10-19 20:54:44 +0000
110+++ lib/lp/registry/interfaces/person.py 2010-10-29 10:43:53 +0000
111@@ -147,6 +147,9 @@
112 StrippedTextLine,
113 )
114 from lp.services.worlddata.interfaces.language import ILanguage
115+from lp.translations.interfaces.hastranslationimports import (
116+ IHasTranslationImports,
117+ )
118
119
120 PRIVATE_TEAM_PREFIX = 'private-'
121@@ -507,7 +510,7 @@
122 class IPersonPublic(IHasBranches, IHasSpecifications, IHasMentoringOffers,
123 IHasMergeProposals, IHasLogo, IHasMugshot, IHasIcon,
124 IHasLocation, IHasRequestedReviews, IObjectWithLocation,
125- IPrivacy, IHasBugs, IHasRecipes):
126+ IPrivacy, IHasBugs, IHasRecipes, IHasTranslationImports):
127 """Public attributes for a Person."""
128
129 id = Int(title=_('ID'), required=True, readonly=True)
130
131=== modified file 'lib/lp/registry/interfaces/product.py'
132--- lib/lp/registry/interfaces/product.py 2010-09-21 09:37:06 +0000
133+++ lib/lp/registry/interfaces/product.py 2010-10-29 10:43:53 +0000
134@@ -134,6 +134,9 @@
135 Title,
136 URIField,
137 )
138+from lp.translations.interfaces.hastranslationimports import (
139+ IHasTranslationImports,
140+ )
141 from lp.translations.interfaces.translationgroup import ITranslationPolicy
142
143 # This is based on the definition of <label> in RFC 1035, section
144@@ -407,9 +410,10 @@
145 IHasBranchVisibilityPolicy, IHasDrivers, IHasExternalBugTracker, IHasIcon,
146 IHasLogo, IHasMentoringOffers, IHasMergeProposals, IHasMilestones,
147 IHasMugshot, IHasOwner, IHasSecurityContact, IHasSprints,
148- ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
149- IOfficialBugTagTargetPublic, IPillar, ISpecificationTarget, IHasRecipes,
150- IHasCodeImports, IServiceUsage):
151+ IHasTranslationImports, ITranslationPolicy, IKarmaContext,
152+ ILaunchpadUsage, IMakesAnnouncements, IOfficialBugTagTargetPublic,
153+ IPillar, ISpecificationTarget, IHasRecipes, IHasCodeImports,
154+ IServiceUsage):
155 """Public IProduct properties."""
156
157 id = Int(title=_('The Project ID'))
158
159=== modified file 'lib/lp/registry/interfaces/productseries.py'
160--- lib/lp/registry/interfaces/productseries.py 2010-10-18 17:05:42 +0000
161+++ lib/lp/registry/interfaces/productseries.py 2010-10-29 10:43:53 +0000
162@@ -73,6 +73,9 @@
163 PersonChoice,
164 Title,
165 )
166+from lp.translations.interfaces.hastranslationimports import (
167+ IHasTranslationImports,
168+ )
169 from lp.translations.interfaces.potemplate import IHasTranslationTemplates
170 from lp.translations.interfaces.translations import (
171 TranslationsBranchImportMode,
172@@ -121,7 +124,7 @@
173 class IProductSeriesPublic(
174 ISeriesMixin, IHasAppointedDriver, IHasOwner, IBugTarget,
175 ISpecificationGoal, IHasMilestones, IHasOfficialBugTags,
176- IHasTranslationTemplates, IServiceUsage):
177+ IHasTranslationImports, IHasTranslationTemplates, IServiceUsage):
178 """Public IProductSeries properties."""
179 # XXX Mark Shuttleworth 2004-10-14: Would like to get rid of id in
180 # interfaces, as soon as SQLobject allows using the object directly
181
182=== modified file 'lib/lp/registry/interfaces/sourcepackage.py'
183--- lib/lp/registry/interfaces/sourcepackage.py 2010-08-20 20:31:18 +0000
184+++ lib/lp/registry/interfaces/sourcepackage.py 2010-10-29 10:43:53 +0000
185@@ -55,12 +55,15 @@
186 IHasMergeProposals,
187 )
188 from lp.soyuz.interfaces.component import IComponent
189+from lp.translations.interfaces.hastranslationimports import (
190+ IHasTranslationImports,
191+ )
192 from lp.translations.interfaces.potemplate import IHasTranslationTemplates
193
194
195 class ISourcePackage(IBugTarget, IHasBranches, IHasMergeProposals,
196 IHasOfficialBugTags, IHasCodeImports,
197- IHasTranslationTemplates):
198+ IHasTranslationImports, IHasTranslationTemplates):
199 """A SourcePackage. See the MagicSourcePackage specification. This
200 interface preserves as much as possible of the old SourcePackage
201 interface from the SourcePackage table, with the new table-less
202
203=== modified file 'lib/lp/registry/model/distribution.py'
204--- lib/lp/registry/model/distribution.py 2010-10-24 12:46:23 +0000
205+++ lib/lp/registry/model/distribution.py 2010-10-29 10:43:53 +0000
206@@ -190,7 +190,7 @@
207 )
208 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
209 from lp.translations.interfaces.translationgroup import TranslationPermission
210-from lp.translations.model.translationimportqueue import (
211+from lp.translations.model.hastranslationimports import (
212 HasTranslationImportsMixin,
213 )
214
215
216=== modified file 'lib/lp/registry/model/distroseries.py'
217--- lib/lp/registry/model/distroseries.py 2010-10-18 04:19:10 +0000
218+++ lib/lp/registry/model/distroseries.py 2010-10-29 10:43:53 +0000
219@@ -179,6 +179,9 @@
220 DistroSeriesLanguage,
221 DummyDistroSeriesLanguage,
222 )
223+from lp.translations.model.hastranslationimports import (
224+ HasTranslationImportsMixin,
225+ )
226 from lp.translations.model.languagepack import LanguagePack
227 from lp.translations.model.pofile import POFile
228 from lp.translations.model.pofiletranslator import POFileTranslator
229@@ -187,9 +190,6 @@
230 POTemplate,
231 TranslationTemplatesCollection,
232 )
233-from lp.translations.model.translationimportqueue import (
234- HasTranslationImportsMixin,
235- )
236
237
238 class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin,
239
240=== modified file 'lib/lp/registry/model/person.py'
241--- lib/lp/registry/model/person.py 2010-10-28 09:35:57 +0000
242+++ lib/lp/registry/model/person.py 2010-10-29 10:43:53 +0000
243@@ -276,7 +276,7 @@
244 from lp.soyuz.interfaces.archivesubscriber import IArchiveSubscriberSet
245 from lp.soyuz.model.archive import Archive
246 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
247-from lp.translations.model.translationimportqueue import (
248+from lp.translations.model.hastranslationimports import (
249 HasTranslationImportsMixin,
250 )
251
252
253=== modified file 'lib/lp/registry/model/product.py'
254--- lib/lp/registry/model/product.py 2010-10-24 13:02:07 +0000
255+++ lib/lp/registry/model/product.py 2010-10-29 10:43:53 +0000
256@@ -170,10 +170,10 @@
257 CustomLanguageCode,
258 HasCustomLanguageCodesMixin,
259 )
260+from lp.translations.model.hastranslationimports import (
261+ HasTranslationImportsMixin,
262+ )
263 from lp.translations.model.potemplate import POTemplate
264-from lp.translations.model.translationimportqueue import (
265- HasTranslationImportsMixin,
266- )
267
268
269 def get_license_status(license_approved, license_reviewed, licenses):
270
271=== modified file 'lib/lp/registry/model/productseries.py'
272--- lib/lp/registry/model/productseries.py 2010-10-18 20:40:05 +0000
273+++ lib/lp/registry/model/productseries.py 2010-10-29 10:43:53 +0000
274@@ -89,6 +89,9 @@
275 from lp.translations.interfaces.translations import (
276 TranslationsBranchImportMode,
277 )
278+from lp.translations.model.hastranslationimports import (
279+ HasTranslationImportsMixin,
280+ )
281 from lp.translations.model.pofile import POFile
282 from lp.translations.model.potemplate import (
283 HasTranslationTemplatesMixin,
284@@ -96,9 +99,6 @@
285 TranslationTemplatesCollection,
286 )
287 from lp.translations.model.productserieslanguage import ProductSeriesLanguage
288-from lp.translations.model.translationimportqueue import (
289- HasTranslationImportsMixin,
290- )
291
292
293 MAX_TIMELINE_MILESTONES = 20
294
295=== modified file 'lib/lp/registry/model/sourcepackage.py'
296--- lib/lp/registry/model/sourcepackage.py 2010-10-03 15:30:06 +0000
297+++ lib/lp/registry/model/sourcepackage.py 2010-10-29 10:43:53 +0000
298@@ -91,13 +91,13 @@
299 )
300 from lp.soyuz.model.publishing import SourcePackagePublishingHistory
301 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
302+from lp.translations.model.hastranslationimports import (
303+ HasTranslationImportsMixin,
304+ )
305 from lp.translations.model.potemplate import (
306 HasTranslationTemplatesMixin,
307 TranslationTemplatesCollection,
308 )
309-from lp.translations.model.translationimportqueue import (
310- HasTranslationImportsMixin,
311- )
312
313
314 class SourcePackageQuestionTargetMixin(QuestionTargetMixin):
315
316=== modified file 'lib/lp/translations/browser/hastranslationimports.py'
317--- lib/lp/translations/browser/hastranslationimports.py 2010-10-29 10:43:52 +0000
318+++ lib/lp/translations/browser/hastranslationimports.py 2010-10-29 10:43:53 +0000
319@@ -241,7 +241,7 @@
320 new_status = status
321 break
322 if new_status is None:
323- # We are trying to set a bogus status.
324+ # We are trying to set a bogus status.
325 # That means that it's a broken request.
326 raise UnexpectedFormData(
327 'Ignored the request to change the status from %s to %s.'
328@@ -361,6 +361,7 @@
329 'value': entry.status.title,
330 'items': items}
331
332+
333 class EntryImportStatusVocabularyFactory:
334 """Factory for a vocabulary containing a list of statuses for import."""
335
336@@ -378,7 +379,7 @@
337 def __call__(self, context):
338 terms = []
339 for status in RosettaImportStatus.items:
340- if (status == self.entry.status or
341+ if (status == self.entry.status or
342 self.entry.canSetStatus(status, self.user)):
343 terms.append(
344 SimpleTerm(status.name, status.name, status.title))
345
346=== modified file 'lib/lp/translations/interfaces/hastranslationimports.py'
347--- lib/lp/translations/interfaces/hastranslationimports.py 2010-10-29 10:43:52 +0000
348+++ lib/lp/translations/interfaces/hastranslationimports.py 2010-10-29 10:43:53 +0000
349@@ -25,7 +25,7 @@
350
351
352 class IHasTranslationImports(Interface):
353- """An entity on which a translation import queue entry is attached.
354+ """An entity that has a translation import queue.
355
356 Examples include `ProductSeries`, `SourcePackage`, `DistroSeries`,
357 and `Person`.
358
359=== modified file 'lib/lp/translations/interfaces/webservice.py'
360--- lib/lp/translations/interfaces/webservice.py 2010-10-29 10:43:52 +0000
361+++ lib/lp/translations/interfaces/webservice.py 2010-10-29 10:43:53 +0000
362@@ -22,5 +22,3 @@
363 ITranslationImportQueue,
364 ITranslationImportQueueEntry,
365 )
366-
367-
368
369=== modified file 'lib/lp/translations/model/approver.py'
370--- lib/lp/translations/model/approver.py 2010-10-29 10:43:52 +0000
371+++ lib/lp/translations/model/approver.py 2010-10-29 10:43:53 +0000
372@@ -114,7 +114,7 @@
373 return entry
374 potemplate = None
375 # Path must be a template path.
376- if not self._potemplates.has_key(entry.path):
377+ if entry.path not in self._potemplates:
378 return entry
379
380 domain = make_domain(entry.path)
381@@ -235,8 +235,9 @@
382 assert (
383 entry.productseries == self._potemplateset.productseries and
384 entry.distroseries == self._potemplateset.distroseries and
385- entry.sourcepackagename == self._potemplateset.sourcepackagename
386- ), ("Entry must be for same target as approver.")
387+ entry.sourcepackagename ==
388+ self._potemplateset.sourcepackagename), (
389+ "Entry must be for same target as approver.")
390
391 # This method is intended to be used to wrap
392 # TranslationImportQueue.addOrUpdateEntry which may return None.
393@@ -254,4 +255,3 @@
394 RosettaImportStatus.APPROVED,
395 getUtility(ILaunchpadCelebrities).rosetta_experts)
396 return entry
397-
398
399=== added file 'lib/lp/translations/model/hastranslationimports.py'
400--- lib/lp/translations/model/hastranslationimports.py 1970-01-01 00:00:00 +0000
401+++ lib/lp/translations/model/hastranslationimports.py 2010-10-29 10:43:53 +0000
402@@ -0,0 +1,36 @@
403+# Copyright 2010 Canonical Ltd. This software is licensed under the
404+# GNU Affero General Public License version 3 (see the file LICENSE).
405+
406+"""Model code for `IHasTranslationImports."""
407+
408+__metaclass__ = type
409+__all__ = [
410+ 'HasTranslationImportsMixin',
411+ ]
412+
413+from zope.component import getUtility
414+
415+from lp.translations.interfaces.translationimportqueue import (
416+ ITranslationImportQueue,
417+ )
418+
419+
420+class HasTranslationImportsMixin:
421+ """Helper class for implementing `IHasTranslationImports`."""
422+
423+ def getFirstEntryToImport(self):
424+ """See `IHasTranslationImports`."""
425+ translation_import_queue = getUtility(ITranslationImportQueue)
426+ return translation_import_queue.getFirstEntryToImport(target=self)
427+
428+ def getTranslationImportQueueEntries(self, import_status=None,
429+ file_extension=None):
430+ """See `IHasTranslationImports`."""
431+ if file_extension is None:
432+ extensions = None
433+ else:
434+ extensions = [file_extension]
435+ translation_import_queue = getUtility(ITranslationImportQueue)
436+ return translation_import_queue.getAllEntries(
437+ target=self, import_status=import_status,
438+ file_extensions=extensions)
439
440=== modified file 'lib/lp/translations/model/pofile.py'
441--- lib/lp/translations/model/pofile.py 2010-10-29 10:43:52 +0000
442+++ lib/lp/translations/model/pofile.py 2010-10-29 10:43:53 +0000
443@@ -534,7 +534,8 @@
444 applicable_template = Coalesce(
445 TranslationMessage.potemplateID, self.potemplate.id)
446 clauses = [
447- TranslationTemplateItem.potmsgsetID == TranslationMessage.potmsgsetID,
448+ TranslationTemplateItem.potmsgsetID ==
449+ TranslationMessage.potmsgsetID,
450 TranslationTemplateItem.potemplate == self.potemplate,
451 TranslationMessage.language == self.language,
452 applicable_template == self.potemplate.id,
453@@ -1103,8 +1104,7 @@
454
455 # Prepare the mail notification.
456 msgsets_imported = self.getTranslationMessages(
457- TranslationMessage.was_obsolete_in_last_import == False
458- ).count()
459+ TranslationMessage.was_obsolete_in_last_import == False).count()
460
461 replacements = collect_import_info(entry_to_import, self, warnings)
462 replacements.update({
463
464=== modified file 'lib/lp/translations/model/translationimportqueue.py'
465--- lib/lp/translations/model/translationimportqueue.py 2010-10-29 10:43:52 +0000
466+++ lib/lp/translations/model/translationimportqueue.py 2010-10-29 10:43:53 +0000
467@@ -6,7 +6,6 @@
468 __metaclass__ = type
469 __all__ = [
470 'collect_import_info',
471- 'HasTranslationImportsMixin',
472 'TranslationImportQueueEntry',
473 'TranslationImportQueue',
474 ]
475@@ -75,9 +74,6 @@
476 from lp.registry.interfaces.sourcepackage import ISourcePackage
477 from lp.services.worlddata.interfaces.language import ILanguageSet
478 from lp.translations.enums import RosettaImportStatus
479-from lp.translations.interfaces.hastranslationimports import (
480- IHasTranslationImports,
481- )
482 from lp.translations.interfaces.pofile import IPOFileSet
483 from lp.translations.interfaces.potemplate import (
484 IPOTemplate,
485@@ -1428,25 +1424,3 @@
486 def remove(self, entry):
487 """See ITranslationImportQueue."""
488 TranslationImportQueueEntry.delete(entry.id)
489-
490-
491-class HasTranslationImportsMixin:
492- """Information related with translation import queue."""
493- implements(IHasTranslationImports)
494-
495- def getFirstEntryToImport(self):
496- """See `IHasTranslationImports`."""
497- translation_import_queue = TranslationImportQueue()
498- return translation_import_queue.getFirstEntryToImport(target=self)
499-
500- def getTranslationImportQueueEntries(self, import_status=None,
501- file_extension=None):
502- """See `IHasTranslationImports`."""
503- if file_extension is None:
504- extensions = None
505- else:
506- extensions = [file_extension]
507- translation_import_queue = getUtility(ITranslationImportQueue)
508- return translation_import_queue.getAllEntries(
509- target=self, import_status=import_status,
510- file_extensions=extensions)
511
512=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py'
513--- lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py 2010-10-29 10:43:52 +0000
514+++ lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py 2010-10-29 10:43:53 +0000
515@@ -145,7 +145,7 @@
516 branch_url = build_params[-1]['branch_url']
517 # The slave receives the public http URL for the branch.
518 self.assertEqual(
519- branch_url,
520+ branch_url,
521 behavior.buildfarmjob.branch.composePublicURL())
522 return d.addCallback(got_dispatch)
523
524@@ -301,7 +301,7 @@
525
526 def got_dispatch((status, info)):
527 dummy_tar = os.path.join(
528- os.path.dirname(__file__),'dummy_templates.tar.gz')
529+ os.path.dirname(__file__), 'dummy_templates.tar.gz')
530 # XXX 2010-10-18 bug=662631
531 # Change this to do non-blocking IO.
532 builder.slave.getFile = lambda sum: open(dummy_tar)
533@@ -313,7 +313,7 @@
534 slave_status = {
535 'builder_status': status[0],
536 'build_status': status[1],
537- 'build_id': status[2]
538+ 'build_id': status[2],
539 }
540 behavior.updateSlaveStatus(status, slave_status)
541 return behavior.updateBuild_WAITING(
542@@ -325,7 +325,7 @@
543 expected_templates = [
544 'po/domain.pot',
545 'po-other/other.pot',
546- 'po-thethird/templ3.pot'
547+ 'po-thethird/templ3.pot',
548 ]
549 list1 = sorted(expected_templates)
550 list2 = sorted([entry.path for entry in entries])
551
552=== modified file 'lib/lp/translations/utilities/tests/test_xpi_search.py'
553--- lib/lp/translations/utilities/tests/test_xpi_search.py 2010-10-29 10:43:52 +0000
554+++ lib/lp/translations/utilities/tests/test_xpi_search.py 2010-10-29 10:43:53 +0000
555@@ -70,7 +70,6 @@
556 u'FooZilla Zilla Thingy'],
557 message_list)
558
559-
560 def test_templateSearchingForMsgIDs(self):
561 """Searching returns no results for internal msg IDs."""
562 entry = self.setUpTranslationImportQueueForTemplate('en-US')