← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:schema-circular-imports-decentralize-translations into launchpad:master.

Commit message:
Move circular import workarounds to lp.translations.interfaces.webservice

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #673083 in Launchpad itself: "Break _schema_circular_imports into per-package import fixes"
  https://bugs.launchpad.net/launchpad/+bug/673083

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/426628
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:schema-circular-imports-decentralize-translations into launchpad:master.
diff --git a/lib/lp/_schema_circular_imports.py b/lib/lp/_schema_circular_imports.py
index c02fdbc..e0bd33a 100644
--- a/lib/lp/_schema_circular_imports.py
+++ b/lib/lp/_schema_circular_imports.py
@@ -95,21 +95,6 @@ from lp.soyuz.interfaces.publishing import (
     )
 from lp.soyuz.interfaces.queue import IPackageUpload
 from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
-from lp.translations.interfaces.hastranslationimports import (
-    IHasTranslationImports,
-    )
-from lp.translations.interfaces.hastranslationtemplates import (
-    IHasTranslationTemplates,
-    )
-from lp.translations.interfaces.pofile import IPOFile
-from lp.translations.interfaces.potemplate import (
-    IPOTemplate,
-    IPOTemplateSharingSubset,
-    IPOTemplateSubset,
-    )
-from lp.translations.interfaces.translationimportqueue import (
-    ITranslationImportQueueEntry,
-    )
 
 
 # IBuilder
@@ -351,11 +336,6 @@ patch_reference_property(
     ISourcePackageRelease, 'source_package_recipe_build',
     ISourcePackageRecipeBuild)
 
-# IHasTranslationImports
-patch_collection_return_type(
-    IHasTranslationImports, 'getTranslationImportQueueEntries',
-    ITranslationImportQueueEntry)
-
 # IIndexedMessage
 patch_reference_property(IIndexedMessage, 'inside', IBugTask)
 
@@ -367,21 +347,6 @@ patch_collection_property(IMessage, 'revisions', IMessageRevision)
 patch_reference_property(IUserToUserEmail, 'sender', IPerson)
 patch_reference_property(IUserToUserEmail, 'recipient', IPerson)
 
-# IHasTranslationTemplates
-patch_collection_return_type(
-    IHasTranslationTemplates, 'getTranslationTemplates', IPOTemplate)
-
-# IPOTemplate
-patch_collection_property(IPOTemplate, 'pofiles', IPOFile)
-patch_reference_property(IPOTemplate, 'product', IProduct)
-
-# IPOTemplateSubset
-patch_reference_property(IPOTemplateSubset, 'distroseries', IDistroSeries)
-patch_reference_property(IPOTemplateSubset, 'productseries', IProductSeries)
-
-# IPOTemplateSharingSubset
-patch_reference_property(IPOTemplateSharingSubset, 'product', IProduct)
-
 # IPerson
 patch_collection_return_type(
     IPerson, 'getBugSubscriberPackages', IDistributionSourcePackage)
diff --git a/lib/lp/translations/interfaces/hastranslationimports.py b/lib/lp/translations/interfaces/hastranslationimports.py
index a8443c0..51af237 100644
--- a/lib/lp/translations/interfaces/hastranslationimports.py
+++ b/lib/lp/translations/interfaces/hastranslationimports.py
@@ -48,8 +48,8 @@ class IHasTranslationImports(Interface):
             title=_("Filename extension"),
             description=_("Show only entries with this filename suffix"),
             required=False))
-    # Really ITranslationImportQueueEntry.  Fixed up in
-    # _schema_circular_imports.py.
+    # Really ITranslationImportQueueEntry, patched in
+    # lp.translations.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version('beta')
diff --git a/lib/lp/translations/interfaces/hastranslationtemplates.py b/lib/lp/translations/interfaces/hastranslationtemplates.py
index 4b9767a..9253820 100644
--- a/lib/lp/translations/interfaces/hastranslationtemplates.py
+++ b/lib/lp/translations/interfaces/hastranslationtemplates.py
@@ -84,6 +84,7 @@ class IHasTranslationTemplates(Interface):
         """
 
     @export_read_operation()
+    # Really IPOTemplate, patched in lp.translations.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @operation_for_version('beta')
     def getTranslationTemplates():
diff --git a/lib/lp/translations/interfaces/potemplate.py b/lib/lp/translations/interfaces/potemplate.py
index 3a7ef3a..164351c 100644
--- a/lib/lp/translations/interfaces/potemplate.py
+++ b/lib/lp/translations/interfaces/potemplate.py
@@ -207,7 +207,7 @@ class IPOTemplate(IRosettaStats):
     pofiles = exported(
         CollectionField(
             title=_("All translation files that exist for this template."),
-            # Really IPOFile, see _schema_circular_imports.py.
+            # Really IPOFile, patched in lp.translations.interfaces.webservice.
             value_type=Reference(schema=Interface)),
         exported_as='translation_files')
 
@@ -228,7 +228,7 @@ class IPOTemplate(IRosettaStats):
     product = Object(
         title=_('The `IProduct` to which this translation template belongs.'),
         required=False, readonly=True,
-        # Really IProduct, see _schema_circular_imports.py.
+        # Really IProduct, patched in lp.translations.interfaces.webservice.
         schema=Interface)
 
     distribution = Object(
@@ -518,13 +518,15 @@ class IPOTemplateSubset(Interface):
     distroseries = Object(
         title=_(
             'The `IDistroSeries` associated with this subset.'),
-        # Really IDistroSeries, see _schema_circular_imports.py.
+        # Really IDistroSeries, patched in
+        # lp.translations.interfaces.webservice.
         schema=Interface)
 
     productseries = Object(
         title=_(
             'The `IProductSeries` associated with this subset.'),
-        # Really IProductSeries, see _schema_circular_imports.py.
+        # Really IProductSeries, patched in
+        # lp.translations.interfaces.webservice.
         schema=Interface)
 
     iscurrent = Bool(
@@ -675,7 +677,7 @@ class IPOTemplateSharingSubset(Interface):
     product = Object(
         title=_(
             'The `IProduct` associated with this subset.'),
-        # Really IProduct, see _schema_circular_imports.py.
+        # Really IProduct, patched in lp.translations.interfaces.webservice.
         schema=Interface)
 
     sourcepackagename = Object(
diff --git a/lib/lp/translations/interfaces/webservice.py b/lib/lp/translations/interfaces/webservice.py
index 2e3e3d4..0ce1123 100644
--- a/lib/lp/translations/interfaces/webservice.py
+++ b/lib/lp/translations/interfaces/webservice.py
@@ -19,14 +19,26 @@ __all__ = [
     'ITranslationImportQueueEntry',
     ]
 
-# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
-# import bugs.  Break this up into a per-package thing.
-from lp import _schema_circular_imports
+from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.registry.interfaces.product import IProduct
+from lp.registry.interfaces.productseries import IProductSeries
+from lp.services.webservice.apihelpers import (
+    patch_collection_property,
+    patch_collection_return_type,
+    patch_reference_property,
+    )
 from lp.translations.interfaces.hastranslationimports import (
     IHasTranslationImports,
     )
+from lp.translations.interfaces.hastranslationtemplates import (
+    IHasTranslationTemplates,
+    )
 from lp.translations.interfaces.pofile import IPOFile
-from lp.translations.interfaces.potemplate import IPOTemplate
+from lp.translations.interfaces.potemplate import (
+    IPOTemplate,
+    IPOTemplateSharingSubset,
+    IPOTemplateSubset,
+    )
 from lp.translations.interfaces.translationgroup import (
     ITranslationGroup,
     ITranslationGroupSet,
@@ -37,4 +49,22 @@ from lp.translations.interfaces.translationimportqueue import (
     )
 
 
-_schema_circular_imports
+# IHasTranslationImports
+patch_collection_return_type(
+    IHasTranslationImports, 'getTranslationImportQueueEntries',
+    ITranslationImportQueueEntry)
+
+# IHasTranslationTemplates
+patch_collection_return_type(
+    IHasTranslationTemplates, 'getTranslationTemplates', IPOTemplate)
+
+# IPOTemplate
+patch_collection_property(IPOTemplate, 'pofiles', IPOFile)
+patch_reference_property(IPOTemplate, 'product', IProduct)
+
+# IPOTemplateSubset
+patch_reference_property(IPOTemplateSubset, 'distroseries', IDistroSeries)
+patch_reference_property(IPOTemplateSubset, 'productseries', IProductSeries)
+
+# IPOTemplateSharingSubset
+patch_reference_property(IPOTemplateSharingSubset, 'product', IProduct)