Merge ~cjwatson/launchpad:schema-circular-imports-decentralize-translations into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 2ce0784472aca871b4a732c2c1a096748ecd5c2d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:schema-circular-imports-decentralize-translations
Merge into: launchpad:master
Diff against target: 195 lines (+45/-47)
5 files modified
lib/lp/_schema_circular_imports.py (+0/-35)
lib/lp/translations/interfaces/hastranslationimports.py (+2/-2)
lib/lp/translations/interfaces/hastranslationtemplates.py (+1/-0)
lib/lp/translations/interfaces/potemplate.py (+7/-5)
lib/lp/translations/interfaces/webservice.py (+35/-5)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+426628@code.launchpad.net

Commit message

Move circular import workarounds to lp.translations.interfaces.webservice

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/_schema_circular_imports.py b/lib/lp/_schema_circular_imports.py
2index c02fdbc..e0bd33a 100644
3--- a/lib/lp/_schema_circular_imports.py
4+++ b/lib/lp/_schema_circular_imports.py
5@@ -95,21 +95,6 @@ from lp.soyuz.interfaces.publishing import (
6 )
7 from lp.soyuz.interfaces.queue import IPackageUpload
8 from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
9-from lp.translations.interfaces.hastranslationimports import (
10- IHasTranslationImports,
11- )
12-from lp.translations.interfaces.hastranslationtemplates import (
13- IHasTranslationTemplates,
14- )
15-from lp.translations.interfaces.pofile import IPOFile
16-from lp.translations.interfaces.potemplate import (
17- IPOTemplate,
18- IPOTemplateSharingSubset,
19- IPOTemplateSubset,
20- )
21-from lp.translations.interfaces.translationimportqueue import (
22- ITranslationImportQueueEntry,
23- )
24
25
26 # IBuilder
27@@ -351,11 +336,6 @@ patch_reference_property(
28 ISourcePackageRelease, 'source_package_recipe_build',
29 ISourcePackageRecipeBuild)
30
31-# IHasTranslationImports
32-patch_collection_return_type(
33- IHasTranslationImports, 'getTranslationImportQueueEntries',
34- ITranslationImportQueueEntry)
35-
36 # IIndexedMessage
37 patch_reference_property(IIndexedMessage, 'inside', IBugTask)
38
39@@ -367,21 +347,6 @@ patch_collection_property(IMessage, 'revisions', IMessageRevision)
40 patch_reference_property(IUserToUserEmail, 'sender', IPerson)
41 patch_reference_property(IUserToUserEmail, 'recipient', IPerson)
42
43-# IHasTranslationTemplates
44-patch_collection_return_type(
45- IHasTranslationTemplates, 'getTranslationTemplates', IPOTemplate)
46-
47-# IPOTemplate
48-patch_collection_property(IPOTemplate, 'pofiles', IPOFile)
49-patch_reference_property(IPOTemplate, 'product', IProduct)
50-
51-# IPOTemplateSubset
52-patch_reference_property(IPOTemplateSubset, 'distroseries', IDistroSeries)
53-patch_reference_property(IPOTemplateSubset, 'productseries', IProductSeries)
54-
55-# IPOTemplateSharingSubset
56-patch_reference_property(IPOTemplateSharingSubset, 'product', IProduct)
57-
58 # IPerson
59 patch_collection_return_type(
60 IPerson, 'getBugSubscriberPackages', IDistributionSourcePackage)
61diff --git a/lib/lp/translations/interfaces/hastranslationimports.py b/lib/lp/translations/interfaces/hastranslationimports.py
62index a8443c0..51af237 100644
63--- a/lib/lp/translations/interfaces/hastranslationimports.py
64+++ b/lib/lp/translations/interfaces/hastranslationimports.py
65@@ -48,8 +48,8 @@ class IHasTranslationImports(Interface):
66 title=_("Filename extension"),
67 description=_("Show only entries with this filename suffix"),
68 required=False))
69- # Really ITranslationImportQueueEntry. Fixed up in
70- # _schema_circular_imports.py.
71+ # Really ITranslationImportQueueEntry, patched in
72+ # lp.translations.interfaces.webservice.
73 @operation_returns_collection_of(Interface)
74 @export_read_operation()
75 @operation_for_version('beta')
76diff --git a/lib/lp/translations/interfaces/hastranslationtemplates.py b/lib/lp/translations/interfaces/hastranslationtemplates.py
77index 4b9767a..9253820 100644
78--- a/lib/lp/translations/interfaces/hastranslationtemplates.py
79+++ b/lib/lp/translations/interfaces/hastranslationtemplates.py
80@@ -84,6 +84,7 @@ class IHasTranslationTemplates(Interface):
81 """
82
83 @export_read_operation()
84+ # Really IPOTemplate, patched in lp.translations.interfaces.webservice.
85 @operation_returns_collection_of(Interface)
86 @operation_for_version('beta')
87 def getTranslationTemplates():
88diff --git a/lib/lp/translations/interfaces/potemplate.py b/lib/lp/translations/interfaces/potemplate.py
89index 3a7ef3a..164351c 100644
90--- a/lib/lp/translations/interfaces/potemplate.py
91+++ b/lib/lp/translations/interfaces/potemplate.py
92@@ -207,7 +207,7 @@ class IPOTemplate(IRosettaStats):
93 pofiles = exported(
94 CollectionField(
95 title=_("All translation files that exist for this template."),
96- # Really IPOFile, see _schema_circular_imports.py.
97+ # Really IPOFile, patched in lp.translations.interfaces.webservice.
98 value_type=Reference(schema=Interface)),
99 exported_as='translation_files')
100
101@@ -228,7 +228,7 @@ class IPOTemplate(IRosettaStats):
102 product = Object(
103 title=_('The `IProduct` to which this translation template belongs.'),
104 required=False, readonly=True,
105- # Really IProduct, see _schema_circular_imports.py.
106+ # Really IProduct, patched in lp.translations.interfaces.webservice.
107 schema=Interface)
108
109 distribution = Object(
110@@ -518,13 +518,15 @@ class IPOTemplateSubset(Interface):
111 distroseries = Object(
112 title=_(
113 'The `IDistroSeries` associated with this subset.'),
114- # Really IDistroSeries, see _schema_circular_imports.py.
115+ # Really IDistroSeries, patched in
116+ # lp.translations.interfaces.webservice.
117 schema=Interface)
118
119 productseries = Object(
120 title=_(
121 'The `IProductSeries` associated with this subset.'),
122- # Really IProductSeries, see _schema_circular_imports.py.
123+ # Really IProductSeries, patched in
124+ # lp.translations.interfaces.webservice.
125 schema=Interface)
126
127 iscurrent = Bool(
128@@ -675,7 +677,7 @@ class IPOTemplateSharingSubset(Interface):
129 product = Object(
130 title=_(
131 'The `IProduct` associated with this subset.'),
132- # Really IProduct, see _schema_circular_imports.py.
133+ # Really IProduct, patched in lp.translations.interfaces.webservice.
134 schema=Interface)
135
136 sourcepackagename = Object(
137diff --git a/lib/lp/translations/interfaces/webservice.py b/lib/lp/translations/interfaces/webservice.py
138index 2e3e3d4..0ce1123 100644
139--- a/lib/lp/translations/interfaces/webservice.py
140+++ b/lib/lp/translations/interfaces/webservice.py
141@@ -19,14 +19,26 @@ __all__ = [
142 'ITranslationImportQueueEntry',
143 ]
144
145-# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
146-# import bugs. Break this up into a per-package thing.
147-from lp import _schema_circular_imports
148+from lp.registry.interfaces.distroseries import IDistroSeries
149+from lp.registry.interfaces.product import IProduct
150+from lp.registry.interfaces.productseries import IProductSeries
151+from lp.services.webservice.apihelpers import (
152+ patch_collection_property,
153+ patch_collection_return_type,
154+ patch_reference_property,
155+ )
156 from lp.translations.interfaces.hastranslationimports import (
157 IHasTranslationImports,
158 )
159+from lp.translations.interfaces.hastranslationtemplates import (
160+ IHasTranslationTemplates,
161+ )
162 from lp.translations.interfaces.pofile import IPOFile
163-from lp.translations.interfaces.potemplate import IPOTemplate
164+from lp.translations.interfaces.potemplate import (
165+ IPOTemplate,
166+ IPOTemplateSharingSubset,
167+ IPOTemplateSubset,
168+ )
169 from lp.translations.interfaces.translationgroup import (
170 ITranslationGroup,
171 ITranslationGroupSet,
172@@ -37,4 +49,22 @@ from lp.translations.interfaces.translationimportqueue import (
173 )
174
175
176-_schema_circular_imports
177+# IHasTranslationImports
178+patch_collection_return_type(
179+ IHasTranslationImports, 'getTranslationImportQueueEntries',
180+ ITranslationImportQueueEntry)
181+
182+# IHasTranslationTemplates
183+patch_collection_return_type(
184+ IHasTranslationTemplates, 'getTranslationTemplates', IPOTemplate)
185+
186+# IPOTemplate
187+patch_collection_property(IPOTemplate, 'pofiles', IPOFile)
188+patch_reference_property(IPOTemplate, 'product', IProduct)
189+
190+# IPOTemplateSubset
191+patch_reference_property(IPOTemplateSubset, 'distroseries', IDistroSeries)
192+patch_reference_property(IPOTemplateSubset, 'productseries', IProductSeries)
193+
194+# IPOTemplateSharingSubset
195+patch_reference_property(IPOTemplateSharingSubset, 'product', IProduct)

Subscribers

People subscribed via source and target branches

to status/vote changes: