launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28729
[Merge] ~cjwatson/launchpad:schema-circular-imports-decentralize-bugs into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:schema-circular-imports-decentralize-bugs into launchpad:master.
Commit message:
Move circular import workarounds to lp.bugs.interfaces.webservice
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/426266
A few patches that are entirely within `lp.bugs.interfaces.bugtracker` also move to that module.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:schema-circular-imports-decentralize-bugs into launchpad:master.
diff --git a/lib/lp/_schema_circular_imports.py b/lib/lp/_schema_circular_imports.py
index 3b692bd..4c17b6b 100644
--- a/lib/lp/_schema_circular_imports.py
+++ b/lib/lp/_schema_circular_imports.py
@@ -16,28 +16,9 @@ from lazr.restful.fields import Reference
from lp.blueprints.interfaces.specification import ISpecification
from lp.blueprints.interfaces.specificationbranch import ISpecificationBranch
-from lp.bugs.interfaces.bug import (
- IBug,
- IFrontPageBugAddForm,
- )
+from lp.bugs.interfaces.bug import IBug
from lp.bugs.interfaces.bugbranch import IBugBranch
-from lp.bugs.interfaces.bugnomination import IBugNomination
-from lp.bugs.interfaces.bugsubscriptionfilter import IBugSubscriptionFilter
-from lp.bugs.interfaces.bugtarget import (
- IBugTarget,
- IHasBugs,
- )
from lp.bugs.interfaces.bugtask import IBugTask
-from lp.bugs.interfaces.bugtracker import (
- IBugTracker,
- IBugTrackerComponent,
- IBugTrackerComponentGroup,
- )
-from lp.bugs.interfaces.bugwatch import IBugWatch
-from lp.bugs.interfaces.structuralsubscription import (
- IStructuralSubscription,
- IStructuralSubscriptionTarget,
- )
from lp.bugs.interfaces.vulnerability import IVulnerability
from lp.buildmaster.interfaces.builder import IBuilder
from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJob
@@ -220,15 +201,6 @@ patch_collection_return_type(
patch_entry_return_type(IHasCodeImports, 'newCodeImport', ICodeImport)
patch_plain_parameter_type(IHasCodeImports, 'newCodeImport', 'owner', IPerson)
-# IBugTask
-
-patch_collection_return_type(IBugTask, 'findSimilarBugs', IBug)
-patch_list_parameter_type(
- IBug, 'getNominations', 'nominations', Reference(schema=IBugNomination))
-patch_entry_return_type(IBug, 'addNomination', IBugNomination)
-patch_entry_return_type(IBug, 'getNominationFor', IBugNomination)
-patch_collection_return_type(IBug, 'getNominations', IBugNomination)
-
# IBuilder
patch_reference_property(IBuilder, 'current_build', IBuildFarmJob)
@@ -512,22 +484,6 @@ patch_reference_property(IPackageUpload, 'distroseries', IDistroSeries)
patch_reference_property(IPackageUpload, 'archive', IArchive)
patch_reference_property(IPackageUpload, 'copy_source_archive', IArchive)
-# IStructuralSubscription
-patch_collection_property(
- IStructuralSubscription, 'bug_filters', IBugSubscriptionFilter)
-patch_entry_return_type(
- IStructuralSubscription, "newBugFilter", IBugSubscriptionFilter)
-patch_reference_property(
- IStructuralSubscription, 'target', IStructuralSubscriptionTarget)
-
-# IStructuralSubscriptionTarget
-patch_reference_property(
- IStructuralSubscriptionTarget, 'parent_subscription_target',
- IStructuralSubscriptionTarget)
-patch_entry_return_type(
- IStructuralSubscriptionTarget, 'addBugSubscriptionFilter',
- IBugSubscriptionFilter)
-
# ISourcePackageRelease
patch_reference_property(
ISourcePackageRelease, 'source_package_recipe_build',
@@ -545,23 +501,6 @@ patch_collection_property(
patch_collection_property(
ISourcePackageRecipe, 'completed_builds', ISourcePackageRecipeBuild)
-# IHasBugs
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'assignee', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'bug_reporter', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'bug_supervisor', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'bug_commenter', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'bug_subscriber', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'owner', IPerson)
-patch_plain_parameter_type(IHasBugs, 'searchTasks', 'affected_user', IPerson)
-patch_plain_parameter_type(
- IHasBugs, 'searchTasks', 'structural_subscriber', IPerson)
-
-# IBugTask
-patch_reference_property(IBugTask, 'owner', IPerson)
-
-# IBugWatch
-patch_reference_property(IBugWatch, 'owner', IPerson)
-
# IHasTranslationImports
patch_collection_return_type(
IHasTranslationImports, 'getTranslationImportQueueEntries',
@@ -578,42 +517,6 @@ patch_collection_property(IMessage, 'revisions', IMessageRevision)
patch_reference_property(IUserToUserEmail, 'sender', IPerson)
patch_reference_property(IUserToUserEmail, 'recipient', IPerson)
-# IBug
-patch_plain_parameter_type(
- IBug, 'addNomination', 'target', IBugTarget)
-patch_plain_parameter_type(
- IBug, 'canBeNominatedFor', 'target', IBugTarget)
-patch_plain_parameter_type(
- IBug, 'getNominationFor', 'target', IBugTarget)
-patch_plain_parameter_type(
- IBug, 'getNominations', 'target', IBugTarget)
-patch_collection_property(IBug, 'linked_merge_proposals', IBranchMergeProposal)
-patch_plain_parameter_type(
- IBug, 'linkMergeProposal', 'merge_proposal', IBranchMergeProposal)
-patch_plain_parameter_type(
- IBug, 'unlinkMergeProposal', 'merge_proposal', IBranchMergeProposal)
-
-
-# IFrontPageBugAddForm
-patch_reference_property(IFrontPageBugAddForm, 'bugtarget', IBugTarget)
-
-# IBugTracker
-patch_reference_property(IBugTracker, 'owner', IPerson)
-patch_entry_return_type(
- IBugTracker, 'getRemoteComponentGroup', IBugTrackerComponentGroup)
-patch_entry_return_type(
- IBugTracker, 'addRemoteComponentGroup', IBugTrackerComponentGroup)
-patch_collection_return_type(
- IBugTracker, 'getAllRemoteComponentGroups', IBugTrackerComponentGroup)
-patch_entry_return_type(
- IBugTracker, 'getRemoteComponentForDistroSourcePackageName',
- IBugTrackerComponent)
-
-## IBugTrackerComponent
-patch_reference_property(
- IBugTrackerComponent, "distro_source_package",
- IDistributionSourcePackage)
-
# IHasTranslationTemplates
patch_collection_return_type(
IHasTranslationTemplates, 'getTranslationTemplates', IPOTemplate)
diff --git a/lib/lp/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
index 624dc3e..526db0f 100644
--- a/lib/lp/bugs/interfaces/bug.py
+++ b/lib/lp/bugs/interfaces/bug.py
@@ -698,6 +698,7 @@ class IBugView(Interface):
"""
@operation_parameters(
+ # Really IBugTarget, patched in lp.bugs.interfaces.webservice.
target=Reference(schema=Interface, title=_("Target"))
)
@export_read_operation()
@@ -711,8 +712,10 @@ class IBugView(Interface):
"""
@operation_parameters(
+ # Really IBugTarget, patched in lp.bugs.interfaces.webservice.
target=Reference(schema=Interface, title=_("Target"))
)
+ # Really IBugNomination, patched in lp.bugs.interfaces.webservice.
@operation_returns_entry(Interface)
@export_read_operation()
@operation_for_version("beta")
@@ -725,14 +728,17 @@ class IBugView(Interface):
"""
@operation_parameters(
+ # Really IBugTarget, patched in lp.bugs.interfaces.webservice.
target=Reference(schema=Interface, title=_("Target"), required=False),
nominations=List(
title=_("Nominations to search through."),
- value_type=Reference(schema=Interface), # IBugNomination
+ # Really IBugNomination, patched in lp.bugs.interfaces.webservice.
+ value_type=Reference(schema=Interface),
required=False,
),
)
- @operation_returns_collection_of(Interface) # IBugNomination
+ # Really IBugNomination, patched in lp.bugs.interfaces.webservice.
+ @operation_returns_collection_of(Interface)
@export_read_operation()
@operation_for_version("beta")
def getNominations(target=None, nominations=None):
@@ -1068,9 +1074,11 @@ class IBugEdit(Interface):
"""IBug attributes that require launchpad.Edit permission."""
@operation_parameters(
+ # Really IBugTarget, patched in lp.bugs.interfaces.webservice.
target=Reference(schema=Interface, title=_("Target"))
)
@call_with(owner=REQUEST_USER)
+ # Really IBugNomination, patched in lp.bugs.interfaces.webservice.
@export_factory_operation(Interface, [])
@operation_for_version("beta")
def addNomination(owner, target):
@@ -1113,7 +1121,8 @@ class IBugEdit(Interface):
@call_with(user=REQUEST_USER)
@operation_parameters(
- # Really IBranchMergeProposal, patched in _schema_circular_imports.py.
+ # Really IBranchMergeProposal, patched in
+ # lp.bugs.interfaces.webservice.
merge_proposal=Reference(
Interface, title=_("Merge proposal"), required=True
)
@@ -1125,7 +1134,8 @@ class IBugEdit(Interface):
@call_with(user=REQUEST_USER)
@operation_parameters(
- # Really IBranchMergeProposal, patched in _schema_circular_imports.py.
+ # Really IBranchMergeProposal, patched in
+ # lp.bugs.interfaces.webservice.
merge_proposal=Reference(
Interface, title=_("Merge proposal"), required=True
)
@@ -1301,7 +1311,7 @@ class IBug(
"Git-based merge proposals)."
),
# Really IBranchMergeProposal, patched in
- # _schema_circular_imports.py.
+ # lp.bugs.interfaces.webservice.
value_type=Reference(schema=Interface),
readonly=True,
),
@@ -1484,7 +1494,10 @@ class IFrontPageBugAddForm(IBugAddForm):
"""Create a bug for any bug target."""
bugtarget = Reference(
- schema=Interface, title=_("Where did you find the bug?"), required=True
+ # Really IBugTarget, patched in lp.bugs.interfaces.webservice.
+ schema=Interface,
+ title=_("Where did you find the bug?"),
+ required=True,
)
diff --git a/lib/lp/bugs/interfaces/bugtarget.py b/lib/lp/bugs/interfaces/bugtarget.py
index 987b56e..57bc0fe 100644
--- a/lib/lp/bugs/interfaces/bugtarget.py
+++ b/lib/lp/bugs/interfaces/bugtarget.py
@@ -66,13 +66,21 @@ search_tasks_params_common = {
"status": copy_field(IBugTaskSearch["status"]),
"importance": copy_field(IBugTaskSearch["importance"]),
"information_type": copy_field(IBugTaskSearch["information_type"]),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"assignee": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"bug_reporter": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"bug_supervisor": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"bug_commenter": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"bug_subscriber": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"structural_subscriber": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"owner": Reference(schema=Interface),
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
"affected_user": Reference(schema=Interface),
"has_patch": copy_field(IBugTaskSearch["has_patch"]),
"has_cve": copy_field(IBugTaskSearch["has_cve"]),
diff --git a/lib/lp/bugs/interfaces/bugtask.py b/lib/lp/bugs/interfaces/bugtask.py
index 9bbe292..8fb2ce2 100644
--- a/lib/lp/bugs/interfaces/bugtask.py
+++ b/lib/lp/bugs/interfaces/bugtask.py
@@ -699,6 +699,7 @@ class IBugTask(IHasBug, IBugTaskDelete):
),
)
owner = exported(
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
Reference(title=_("The owner"), schema=Interface, readonly=True)
)
target = exported(
@@ -772,7 +773,8 @@ class IBugTask(IHasBug, IBugTaskDelete):
)
)
- @operation_returns_collection_of(Interface) # Actually IBug.
+ # Really IBug, patched in lp.bugs.interfaces.webservice.
+ @operation_returns_collection_of(Interface)
@call_with(user=REQUEST_USER, limit=10)
@export_read_operation()
@operation_for_version("beta")
diff --git a/lib/lp/bugs/interfaces/bugtracker.py b/lib/lp/bugs/interfaces/bugtracker.py
index c5bfaa6..3f383e3 100644
--- a/lib/lp/bugs/interfaces/bugtracker.py
+++ b/lib/lp/bugs/interfaces/bugtracker.py
@@ -44,7 +44,11 @@ from lp import _
from lp.app.validators import LaunchpadValidationError
from lp.app.validators.name import name_validator
from lp.services.fields import ContentNameField, StrippedTextLine, URIField
-from lp.services.webservice.apihelpers import patch_reference_property
+from lp.services.webservice.apihelpers import (
+ patch_collection_return_type,
+ patch_entry_return_type,
+ patch_reference_property,
+)
LOCATION_SCHEMES_ALLOWED = "http", "https", "mailto"
@@ -316,7 +320,9 @@ class IBugTracker(Interface):
exported_as="base_url_aliases",
)
owner = exported(
- Reference(title=_("Owner"), schema=Interface), exported_as="registrant"
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
+ Reference(title=_("Owner"), schema=Interface),
+ exported_as="registrant",
)
contactdetails = exported(
Text(
@@ -447,6 +453,7 @@ class IBugTracker(Interface):
title="The name of the remote component group", required=True
)
)
+ # Really IBugTrackerComponentGroup, patched below.
@operation_returns_entry(Interface)
@export_write_operation()
@operation_for_version("beta")
@@ -454,6 +461,7 @@ class IBugTracker(Interface):
"""Adds a new component group to the bug tracker"""
@export_read_operation()
+ # Really IBugTrackerComponentGroup, patched below.
@operation_returns_collection_of(Interface)
@operation_for_version("beta")
def getAllRemoteComponentGroups():
@@ -464,6 +472,7 @@ class IBugTracker(Interface):
title="The name of the remote component group", required=True
)
)
+ # Really IBugTrackerComponentGroup, patched below.
@operation_returns_entry(Interface)
@export_read_operation()
@operation_for_version("beta")
@@ -481,6 +490,7 @@ class IBugTracker(Interface):
title="The source package name", required=True
),
)
+ # Really IBugTrackerComponentGroup, patched below.
@operation_returns_entry(Interface)
@export_read_operation()
@operation_for_version("devel")
@@ -677,6 +687,8 @@ class IBugTrackerComponent(Interface):
distro_source_package = exported(
Reference(
+ # Really IDistributionSourcePackage, patched in
+ # lp.bugs.interfaces.webservice.
Interface,
title=_("Distribution Source Package"),
description=_(
@@ -688,6 +700,7 @@ class IBugTrackerComponent(Interface):
)
component_group = exported(
+ # Really IBugTrackerComponentGroup, patched below.
Reference(title=_("Component Group"), schema=Interface)
)
@@ -729,8 +742,21 @@ class IBugTrackerComponentGroup(Interface):
"""Adds a component to be tracked as part of this component group"""
-# Patch in a mutual reference between IBugTrackerComponent and
-# IBugTrackerComponentGroup.
+# Patch in some mutual references.
+patch_entry_return_type(
+ IBugTracker, "getRemoteComponentGroup", IBugTrackerComponentGroup
+)
+patch_entry_return_type(
+ IBugTracker, "addRemoteComponentGroup", IBugTrackerComponentGroup
+)
+patch_collection_return_type(
+ IBugTracker, "getAllRemoteComponentGroups", IBugTrackerComponentGroup
+)
+patch_entry_return_type(
+ IBugTracker,
+ "getRemoteComponentForDistroSourcePackageName",
+ IBugTrackerComponent,
+)
patch_reference_property(
IBugTrackerComponent, "component_group", IBugTrackerComponentGroup
)
diff --git a/lib/lp/bugs/interfaces/bugwatch.py b/lib/lp/bugs/interfaces/bugwatch.py
index 7192697..e4204cf 100644
--- a/lib/lp/bugs/interfaces/bugwatch.py
+++ b/lib/lp/bugs/interfaces/bugwatch.py
@@ -221,7 +221,11 @@ class IBugWatch(IHasBug):
)
owner = exported(
Reference(
- title=_("Owner"), required=True, readonly=True, schema=Interface
+ title=_("Owner"),
+ required=True,
+ readonly=True,
+ # Really IPerson, patched in lp.bugs.interfaces.webservice.
+ schema=Interface,
)
)
activity = Attribute("The activity history of this BugWatch.")
diff --git a/lib/lp/bugs/interfaces/structuralsubscription.py b/lib/lp/bugs/interfaces/structuralsubscription.py
index a24f970..ad908bf 100644
--- a/lib/lp/bugs/interfaces/structuralsubscription.py
+++ b/lib/lp/bugs/interfaces/structuralsubscription.py
@@ -85,7 +85,9 @@ class IStructuralSubscriptionPublic(Interface):
target = exported(
Reference(
- schema=Interface, # IStructuralSubscriptionTarget
+ # Really IStructuralSubscriptionTarget, patched in
+ # lp.bugs.interfaces.webservice.
+ schema=Interface,
required=True,
readonly=True,
title=_("The structure to which this subscription belongs."),
@@ -97,14 +99,17 @@ class IStructuralSubscriptionPublic(Interface):
title=_("List of bug filters that narrow this subscription."),
readonly=True,
required=False,
+ # Really IBugSubscriptionFilter, patched in
+ # lp.bugs.interfaces.webservice.
value_type=Reference(schema=Interface),
)
- ) # IBugSubscriptionFilter
+ )
class IStructuralSubscriptionRestricted(Interface):
"""The restricted parts of a subscription to a Launchpad structure."""
+ # Really IBugSubscriptionFilter, patched in lp.bugs.interfaces.webservice.
@export_factory_operation(Interface, [])
@operation_for_version("beta")
def newBugFilter():
@@ -223,7 +228,8 @@ class IStructuralSubscriptionTargetWrite(Interface):
)
)
@call_with(subscribed_by=REQUEST_USER)
- @export_factory_operation(Interface, []) # Really IBugSubscriptionFilter
+ # Really IBugSubscriptionFilter, patched in lp.bugs.interfaces.webservice.
+ @export_factory_operation(Interface, [])
@operation_for_version("beta")
def addBugSubscriptionFilter(subscriber, subscribed_by):
"""Add a bug subscription filter for this structure.
diff --git a/lib/lp/bugs/interfaces/webservice.py b/lib/lp/bugs/interfaces/webservice.py
index 809f6a7..3524273 100644
--- a/lib/lp/bugs/interfaces/webservice.py
+++ b/lib/lp/bugs/interfaces/webservice.py
@@ -43,10 +43,9 @@ __all__ = [
"UserCannotEditBugTaskStatus",
]
-# 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.bugs.interfaces.bug import IBug
+from lazr.restful.fields import Reference
+
+from lp.bugs.interfaces.bug import IBug, IFrontPageBugAddForm
from lp.bugs.interfaces.bugactivity import IBugActivity
from lp.bugs.interfaces.bugattachment import IBugAttachment
from lp.bugs.interfaces.bugbranch import IBugBranch
@@ -83,5 +82,83 @@ from lp.bugs.interfaces.structuralsubscription import (
IStructuralSubscriptionTarget,
)
from lp.bugs.interfaces.vulnerability import IVulnerability
+from lp.code.interfaces.branchmergeproposal import IBranchMergeProposal
+from lp.registry.interfaces.distributionsourcepackage import (
+ IDistributionSourcePackage,
+)
+from lp.registry.interfaces.person import IPerson
+from lp.services.webservice.apihelpers import (
+ patch_collection_property,
+ patch_collection_return_type,
+ patch_entry_return_type,
+ patch_list_parameter_type,
+ patch_plain_parameter_type,
+ patch_reference_property,
+)
+
+# IBug
+patch_plain_parameter_type(IBug, "addNomination", "target", IBugTarget)
+patch_entry_return_type(IBug, "addNomination", IBugNomination)
+patch_plain_parameter_type(IBug, "canBeNominatedFor", "target", IBugTarget)
+patch_plain_parameter_type(IBug, "getNominationFor", "target", IBugTarget)
+patch_entry_return_type(IBug, "getNominationFor", IBugNomination)
+patch_plain_parameter_type(IBug, "getNominations", "target", IBugTarget)
+patch_list_parameter_type(
+ IBug, "getNominations", "nominations", Reference(schema=IBugNomination)
+)
+patch_collection_return_type(IBug, "getNominations", IBugNomination)
+patch_collection_property(IBug, "linked_merge_proposals", IBranchMergeProposal)
+patch_plain_parameter_type(
+ IBug, "linkMergeProposal", "merge_proposal", IBranchMergeProposal
+)
+patch_plain_parameter_type(
+ IBug, "unlinkMergeProposal", "merge_proposal", IBranchMergeProposal
+)
+
+# IBugTask
+patch_reference_property(IBugTask, "owner", IPerson)
+patch_collection_return_type(IBugTask, "findSimilarBugs", IBug)
+
+# IBugTracker
+patch_reference_property(IBugTracker, "owner", IPerson)
+
+# IBugTrackerComponent
+patch_reference_property(
+ IBugTrackerComponent, "distro_source_package", IDistributionSourcePackage
+)
-_schema_circular_imports
+# IBugWatch
+patch_reference_property(IBugWatch, "owner", IPerson)
+
+# IFrontPageBugAddForm
+patch_reference_property(IFrontPageBugAddForm, "bugtarget", IBugTarget)
+
+# IHasBugs
+patch_plain_parameter_type(IHasBugs, "searchTasks", "assignee", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "bug_reporter", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "bug_supervisor", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "bug_commenter", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "bug_subscriber", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "owner", IPerson)
+patch_plain_parameter_type(IHasBugs, "searchTasks", "affected_user", IPerson)
+patch_plain_parameter_type(
+ IHasBugs, "searchTasks", "structural_subscriber", IPerson
+)
+
+# IStructuralSubscription
+patch_collection_property(
+ IStructuralSubscription, "bug_filters", IBugSubscriptionFilter
+)
+patch_entry_return_type(
+ IStructuralSubscription, "newBugFilter", IBugSubscriptionFilter
+)
+patch_reference_property(
+ IStructuralSubscription, "target", IStructuralSubscriptionTarget
+)
+
+# IStructuralSubscriptionTarget
+patch_entry_return_type(
+ IStructuralSubscriptionTarget,
+ "addBugSubscriptionFilter",
+ IBugSubscriptionFilter,
+)
References