launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18963
[Merge] lp:~cjwatson/launchpad/zope-component-class-decorators into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/zope-component-class-decorators into lp:launchpad.
Commit message:
Switch zope.component users from class advice to class decorators.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/zope-component-class-decorators/+merge/264276
Switch zope.component users from class advice to class decorators.
This follows on from https://code.launchpad.net/~cjwatson/launchpad/zope-interface-class-decorators/+merge/264175, but there were many fewer users of adapts() so I just did it all by hand and it's much shorter. I renamed a few existing "adapter" local variables out of the way to avoid confusion.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/zope-component-class-decorators into lp:launchpad.
=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py 2015-07-08 16:05:11 +0000
+++ lib/lp/app/browser/tales.py 2015-07-09 12:29:31 +0000
@@ -24,7 +24,7 @@
import pytz
from z3c.ptcompat import ViewPageTemplateFile
from zope.component import (
- adapts,
+ adapter,
getMultiAdapter,
getUtility,
queryAdapter,
@@ -110,8 +110,8 @@
"""Return the equivalent of obj/fmt:link as a string."""
if obj is None:
return empty_value
- adapter = queryAdapter(obj, IPathAdapter, 'fmt')
- link = getattr(adapter, 'link', None)
+ fmt_adapter = queryAdapter(obj, IPathAdapter, 'fmt')
+ link = getattr(fmt_adapter, 'link', None)
if link is None:
raise NotImplementedError("Missing link function on adapter.")
return link(view_name)
@@ -2517,10 +2517,9 @@
path = TextLine(title=u'The absolute path to this main template.')
+@adapter(LaunchpadLayer)
@implementer(IMainTemplateFile)
class LaunchpadLayerToMainTemplateAdapter:
- adapts(LaunchpadLayer)
-
def __init__(self, context):
here = os.path.dirname(os.path.realpath(__file__))
self.path = os.path.join(here, '../templates/base-layout.pt')
=== modified file 'lib/lp/app/longpoll/tests/test_longpoll.py'
--- lib/lp/app/longpoll/tests/test_longpoll.py 2015-07-08 16:05:11 +0000
+++ lib/lp/app/longpoll/tests/test_longpoll.py 2015-07-09 12:29:31 +0000
@@ -6,7 +6,7 @@
__metaclass__ = type
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import (
@@ -42,11 +42,10 @@
self.ident = ident
+@adapter(IFakeObject)
@implementer(ILongPollEvent)
class FakeEvent:
- adapts(IFakeObject)
-
def __init__(self, source):
self.source = source
=== modified file 'lib/lp/bugs/browser/bugbranch.py'
--- lib/lp/bugs/browser/bugbranch.py 2015-07-08 16:05:11 +0000
+++ lib/lp/bugs/browser/bugbranch.py 2015-07-09 12:29:31 +0000
@@ -13,7 +13,7 @@
from lazr.restful.interfaces import IWebServiceClientRequest
from zope.component import (
- adapts,
+ adapter,
getMultiAdapter,
)
from zope.interface import (
@@ -138,10 +138,9 @@
bug.linkBranch(branch=self.context, registrant=self.user)
+@adapter(IBugBranch, IWebServiceClientRequest)
@implementer(Interface)
class BugBranchXHTMLRepresentation:
- adapts(IBugBranch, IWebServiceClientRequest)
-
def __init__(self, branch, request):
self.branch = branch
self.request = request
=== modified file 'lib/lp/bugs/browser/bugcomment.py'
--- lib/lp/bugs/browser/bugcomment.py 2015-07-08 16:05:11 +0000
+++ lib/lp/bugs/browser/bugcomment.py 2015-07-09 12:29:31 +0000
@@ -25,7 +25,7 @@
from lazr.delegates import delegates
from lazr.restful.interfaces import IWebServiceClientRequest
from zope.component import (
- adapts,
+ adapter,
getMultiAdapter,
getUtility,
)
@@ -350,10 +350,9 @@
expand_reply_box = True
+@adapter(IBugComment, IWebServiceClientRequest)
@implementer(Interface)
class BugCommentXHTMLRepresentation:
- adapts(IBugComment, IWebServiceClientRequest)
-
def __init__(self, comment, request):
self.comment = comment
self.request = request
=== modified file 'lib/lp/bugs/model/structuralsubscription.py'
--- lib/lp/bugs/model/structuralsubscription.py 2015-07-08 16:05:11 +0000
+++ lib/lp/bugs/model/structuralsubscription.py 2015-07-09 12:29:31 +0000
@@ -38,7 +38,7 @@
Store,
)
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import implementer
@@ -187,10 +187,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IDistroSeries)
class DistroSeriesTargetHelper:
"""A helper for `IDistroSeries`s."""
- adapts(IDistroSeries)
-
target_type_display = 'distribution series'
def __init__(self, target):
@@ -202,10 +201,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IProjectGroup)
class ProjectGroupTargetHelper:
"""A helper for `IProjectGroup`s."""
- adapts(IProjectGroup)
-
target_type_display = 'project group'
def __init__(self, target):
@@ -217,10 +215,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IDistributionSourcePackage)
class DistributionSourcePackageTargetHelper:
"""A helper for `IDistributionSourcePackage`s."""
- adapts(IDistributionSourcePackage)
-
target_type_display = 'package'
def __init__(self, target):
@@ -239,10 +236,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IMilestone)
class MilestoneTargetHelper:
"""A helper for `IMilestone`s."""
- adapts(IMilestone)
-
target_type_display = 'milestone'
def __init__(self, target):
@@ -254,10 +250,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IProduct)
class ProductTargetHelper:
"""A helper for `IProduct`s."""
- adapts(IProduct)
-
target_type_display = 'project'
def __init__(self, target):
@@ -275,10 +270,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IProductSeries)
class ProductSeriesTargetHelper:
"""A helper for `IProductSeries`s."""
- adapts(IProductSeries)
-
target_type_display = 'project series'
def __init__(self, target):
@@ -290,10 +284,9 @@
@implementer(IStructuralSubscriptionTargetHelper)
+@adapter(IDistribution)
class DistributionTargetHelper:
"""A helper for `IDistribution`s."""
- adapts(IDistribution)
-
target_type_display = 'distribution'
def __init__(self, target):
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2015-07-09 12:29:31 +0000
@@ -36,7 +36,7 @@
)
import simplejson
from zope.component import (
- adapts,
+ adapter,
getMultiAdapter,
getUtility,
)
@@ -1389,10 +1389,9 @@
return self.context
+@adapter(IPreviewDiff, IWebServiceClientRequest)
@implementer(Interface)
class PreviewDiffHTMLRepresentation:
- adapts(IPreviewDiff, IWebServiceClientRequest)
-
def __init__(self, diff, request):
self.diff = diff
self.request = request
=== modified file 'lib/lp/code/model/branchlookup.py'
--- lib/lp/code/model/branchlookup.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/branchlookup.py 2015-07-09 12:29:31 +0000
@@ -22,7 +22,7 @@
Select,
)
from zope.component import (
- adapts,
+ adapter,
getUtility,
queryMultiAdapter,
)
@@ -119,6 +119,7 @@
self.context = context
+@adapter(IProduct)
@implementer(ILinkedBranchTraversable)
class ProductTraversable(_BaseTraversable):
"""Linked branch traversable for products.
@@ -126,8 +127,6 @@
From here, you can traverse to a product series.
"""
- adapts(IProduct)
-
def traverse(self, name, segments):
"""See `ITraversable`.
@@ -141,6 +140,7 @@
return series
+@adapter(IDistribution)
@implementer(ILinkedBranchTraversable)
class DistributionTraversable(_BaseTraversable):
"""Linked branch traversable for distributions.
@@ -148,8 +148,6 @@
From here, you can traverse to a distribution series.
"""
- adapts(IDistribution)
-
def traverse(self, name, segments):
"""See `ITraversable`."""
try:
@@ -164,6 +162,7 @@
return sourcepackage
+@adapter(IDistroSeries, DBItem)
@implementer(ILinkedBranchTraversable)
class DistroSeriesTraversable:
"""Linked branch traversable for distribution series.
@@ -171,8 +170,6 @@
From here, you can traverse to a source package.
"""
- adapts(IDistroSeries, DBItem)
-
def __init__(self, distroseries, pocket):
self.distroseries = distroseries
self.pocket = pocket
=== modified file 'lib/lp/code/model/defaultgit.py'
--- lib/lp/code/model/defaultgit.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/defaultgit.py 2015-07-09 12:29:31 +0000
@@ -8,7 +8,7 @@
# adapting another object.
__all__ = []
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from lp.code.interfaces.defaultgit import ICanHasDefaultGitRepository
@@ -39,12 +39,11 @@
return not self == other
+@adapter(IProduct)
@implementer(ICanHasDefaultGitRepository)
class ProjectDefaultGitRepository(BaseDefaultGitRepository):
"""Implement a default Git repository for a project."""
- adapts(IProduct)
-
sort_order = 0
def __init__(self, project):
@@ -56,12 +55,11 @@
return self.context.name
+@adapter(IDistributionSourcePackage)
@implementer(ICanHasDefaultGitRepository)
class PackageDefaultGitRepository(BaseDefaultGitRepository):
"""Implement a default Git repository for a distribution source package."""
- adapts(IDistributionSourcePackage)
-
sort_order = 0
def __init__(self, distro_source_package):
@@ -75,12 +73,11 @@
self.context.sourcepackagename.name)
+@adapter(IPersonProduct)
@implementer(ICanHasDefaultGitRepository)
class OwnerProjectDefaultGitRepository(BaseDefaultGitRepository):
"""Implement an owner's default Git repository for a project."""
- adapts(IPersonProduct)
-
sort_order = 1
def __init__(self, person_project):
@@ -92,13 +89,12 @@
return "~%s/%s" % (self.context.person.name, self.context.product.name)
+@adapter(IPersonDistributionSourcePackage)
@implementer(ICanHasDefaultGitRepository)
class OwnerPackageDefaultGitRepository(BaseDefaultGitRepository):
"""Implement an owner's default Git repository for a distribution source
package."""
- adapts(IPersonDistributionSourcePackage)
-
sort_order = 1
def __init__(self, person_distro_source_package):
=== modified file 'lib/lp/code/model/gitlookup.py'
--- lib/lp/code/model/gitlookup.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/gitlookup.py 2015-07-09 12:29:31 +0000
@@ -13,7 +13,7 @@
URI,
)
from zope.component import (
- adapts,
+ adapter,
getUtility,
queryMultiAdapter,
)
@@ -129,6 +129,7 @@
return owner, self.context, repository
+@adapter(IProduct)
@implementer(IGitTraversable)
class ProjectGitTraversable(_BaseGitTraversable):
"""Git repository traversable for projects.
@@ -136,12 +137,11 @@
From here, you can traverse to a named project repository.
"""
- adapts(IProduct)
-
def getNamespace(self, owner):
return getUtility(IGitNamespaceSet).get(owner, project=self.context)
+@adapter(IDistribution)
@implementer(IGitTraversable)
class DistributionGitTraversable(_BaseGitTraversable):
"""Git repository traversable for distributions.
@@ -149,8 +149,6 @@
From here, you can traverse to a distribution source package.
"""
- adapts(IDistribution)
-
# Marker for references to Git URL layouts: ##GITNAMESPACE##
def traverse(self, owner, name, segments):
"""See `IGitTraversable`.
@@ -175,6 +173,7 @@
return owner, distro_source_package, None
+@adapter(IDistributionSourcePackage)
@implementer(IGitTraversable)
class DistributionSourcePackageGitTraversable(_BaseGitTraversable):
"""Git repository traversable for distribution source packages.
@@ -182,14 +181,13 @@
From here, you can traverse to a named package repository.
"""
- adapts(IDistributionSourcePackage)
-
def getNamespace(self, owner):
return getUtility(IGitNamespaceSet).get(
owner, distribution=self.context.distribution,
sourcepackagename=self.context.sourcepackagename)
+@adapter(IPerson)
@implementer(IGitTraversable)
class PersonGitTraversable(_BaseGitTraversable):
"""Git repository traversable for people.
@@ -198,8 +196,6 @@
project or a distribution with a person context.
"""
- adapts(IPerson)
-
def getNamespace(self, owner):
return getUtility(IGitNamespaceSet).get(owner)
=== modified file 'lib/lp/code/model/linkedbranch.py'
--- lib/lp/code/model/linkedbranch.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/linkedbranch.py 2015-07-09 12:29:31 +0000
@@ -12,7 +12,7 @@
EnumeratedType,
Item,
)
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from lp.archivepublisher.debversion import Version
@@ -45,12 +45,11 @@
return cmp(self.sort_order, other.sort_order)
+@adapter(IProductSeries)
@implementer(ICanHasLinkedBranch)
class ProductSeriesLinkedBranch(BaseLinkedBranch):
"""Implement a linked branch for a product series."""
- adapts(IProductSeries)
-
sort_order = LinkedBranchOrder.PRODUCT_SERIES
def __init__(self, product_series):
@@ -91,12 +90,11 @@
self.product_series.branch = branch
+@adapter(IProduct)
@implementer(ICanHasLinkedBranch)
class ProductLinkedBranch(BaseLinkedBranch):
"""Implement a linked branch for a product."""
- adapts(IProduct)
-
sort_order = LinkedBranchOrder.PRODUCT
def __init__(self, product):
@@ -129,12 +127,11 @@
branch, registrant)
+@adapter(ISuiteSourcePackage)
@implementer(ICanHasLinkedBranch)
class PackageLinkedBranch(BaseLinkedBranch):
"""Implement a linked branch for a source package pocket."""
- adapts(ISuiteSourcePackage)
-
sort_order = LinkedBranchOrder.SUITE_SOURCE_PACKAGE
def __init__(self, suite_sourcepackage):
@@ -182,12 +179,11 @@
package.setBranch(pocket, branch, registrant)
+@adapter(IDistributionSourcePackage)
@implementer(ICanHasLinkedBranch)
class DistributionPackageLinkedBranch(BaseLinkedBranch):
"""Implement a linked branch for an `IDistributionSourcePackage`."""
- adapts(IDistributionSourcePackage)
-
sort_order = LinkedBranchOrder.DISTRIBUTION_SOURCE_PACKAGE
def __init__(self, distribution_sourcepackage):
=== modified file 'lib/lp/code/model/recipebuilder.py'
--- lib/lp/code/model/recipebuilder.py 2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/recipebuilder.py 2015-07-09 12:29:31 +0000
@@ -10,7 +10,7 @@
import traceback
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from zope.security.proxy import removeSecurityProxy
@@ -31,12 +31,11 @@
)
+@adapter(ISourcePackageRecipeBuild)
@implementer(IBuildFarmJobBehaviour)
class RecipeBuildBehaviour(BuildFarmJobBehaviourBase):
"""How to build a recipe on the build farm."""
- adapts(ISourcePackageRecipeBuild)
-
# The list of build status values for which email notifications are
# allowed to be sent. It is up to each callback as to whether it will
# consider sending a notification but it won't do so if the status is not
=== modified file 'lib/lp/registry/browser/distroseriesdifference.py'
--- lib/lp/registry/browser/distroseriesdifference.py 2015-07-08 16:05:11 +0000
+++ lib/lp/registry/browser/distroseriesdifference.py 2015-07-09 12:29:31 +0000
@@ -12,7 +12,7 @@
from lazr.restful.interfaces import IWebServiceClientRequest
from z3c.ptcompat import ViewPageTemplateFile
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.formlib.itemswidgets import RadioWidget
@@ -266,11 +266,10 @@
return comment.comment.message
+@adapter(IDistroSeriesDifferenceComment, IWebServiceClientRequest)
@implementer(Interface)
class CommentXHTMLRepresentation(LaunchpadView):
"""Render individual comments when requested via the API."""
- adapts(IDistroSeriesDifferenceComment, IWebServiceClientRequest)
-
template = ViewPageTemplateFile(
'../templates/distroseriesdifferencecomment-fragment.pt')
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py 2015-07-09 10:44:18 +0000
+++ lib/lp/registry/browser/person.py 2015-07-09 12:29:31 +0000
@@ -77,7 +77,7 @@
from storm.zope.interfaces import IResultSet
from z3c.ptcompat import ViewPageTemplateFile
from zope.component import (
- adapts,
+ adapter,
getUtility,
queryMultiAdapter,
)
@@ -4397,10 +4397,9 @@
classImplements(PersonIndexView, IPersonIndexMenu)
+@adapter(IPerson, IWebServiceClientRequest)
@implementer(Interface)
class PersonXHTMLRepresentation:
- adapts(IPerson, IWebServiceClientRequest)
-
def __init__(self, person, request):
self.person = person
self.request = request
=== modified file 'lib/lp/registry/model/personroles.py'
--- lib/lp/registry/model/personroles.py 2015-07-08 16:05:11 +0000
+++ lib/lp/registry/model/personroles.py 2015-07-09 12:29:31 +0000
@@ -7,7 +7,7 @@
__all__ = ['PersonRoles']
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import implementer
@@ -22,10 +22,9 @@
)
+@adapter(IPerson)
@implementer(IPersonRoles)
class PersonRoles:
- adapts(IPerson)
-
def __init__(self, person):
self.person = person
self._celebrities = getUtility(ILaunchpadCelebrities)
=== modified file 'lib/lp/services/librarian/model.py'
--- lib/lp/services/librarian/model.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/librarian/model.py 2015-07-09 12:29:31 +0000
@@ -33,7 +33,7 @@
Store,
)
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import (
@@ -225,11 +225,11 @@
self.close()
+@adapter(ILibraryFileAlias, Interface)
@implementer(ILibraryFileAliasWithParent)
class LibraryFileAliasWithParent:
"""A LibraryFileAlias variant that has a parent."""
- adapts(ILibraryFileAlias, Interface)
delegates(ILibraryFileAlias)
def __init__(self, libraryfile, parent):
=== modified file 'lib/lp/services/longpoll/adapters/event.py'
--- lib/lp/services/longpoll/adapters/event.py 2011-09-23 16:36:56 +0000
+++ lib/lp/services/longpoll/adapters/event.py 2015-07-09 12:29:31 +0000
@@ -34,9 +34,10 @@
Sub-classes need to define the `event_key` property and declare something
along the lines of::
+ @adapter(IAwesomeThing)
+ @implementer(ILongPollEvent)
class LongPollAwesomeThingEvent(LongPollEvent):
- adapts(IAwesomeThing)
- implements(ILongPollEvent)
+ ...
Alternatively, use the `long_poll_event` class decorator::
=== modified file 'lib/lp/services/longpoll/adapters/subscriber.py'
--- lib/lp/services/longpoll/adapters/subscriber.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/longpoll/adapters/subscriber.py 2015-07-09 12:29:31 +0000
@@ -13,7 +13,7 @@
from lazr.restful.interfaces import IJSONRequestCache
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import implementer
@@ -29,11 +29,10 @@
return "longpoll.subscribe.%s" % uuid4()
+@adapter(IApplicationRequest)
@implementer(ILongPollSubscriber)
class LongPollApplicationRequestSubscriber:
- adapts(IApplicationRequest)
-
def __init__(self, request):
self.request = request
=== modified file 'lib/lp/services/openid/adapters/openid.py'
--- lib/lp/services/openid/adapters/openid.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/openid/adapters/openid.py 2015-07-09 12:29:31 +0000
@@ -10,10 +10,7 @@
'OpenIDPersistentIdentity',
]
-from zope.component import (
- adapter,
- adapts,
- )
+from zope.component import adapter
from zope.interface import implementer
from lp.registry.interfaces.person import IPerson
@@ -33,12 +30,11 @@
return config.launchpad.openid_provider_root + '+openid'
+@adapter(IAccount)
@implementer(IOpenIDPersistentIdentity)
class OpenIDPersistentIdentity:
"""A persistent OpenID identifier for a user."""
- adapts(IAccount)
-
def __init__(self, account):
self.account = account
=== modified file 'lib/lp/services/webapp/batching.py'
--- lib/lp/services/webapp/batching.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/webapp/batching.py 2015-07-09 12:29:31 +0000
@@ -25,7 +25,7 @@
from storm.properties import PropertyColumn
from storm.store import EmptyResultSet
from storm.zope.interfaces import IResultSet
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from zope.interface.common.sequence import IFiniteSequence
from zope.security.proxy import (
@@ -49,11 +49,10 @@
from lp.services.webapp.publisher import LaunchpadView
+@adapter(IResultSet)
@implementer(IFiniteSequence)
class FiniteSequenceAdapter:
- adapts(IResultSet)
-
def __init__(self, context):
self.context = context
=== modified file 'lib/lp/services/webapp/preferredcharsets.py'
--- lib/lp/services/webapp/preferredcharsets.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/webapp/preferredcharsets.py 2015-07-09 12:29:31 +0000
@@ -7,18 +7,17 @@
__all__ = ['Utf8PreferredCharsets']
-from zope.component import adapts
+from zope.component import adapter
from zope.i18n.interfaces import IUserPreferredCharsets
from zope.interface import implementer
from zope.publisher.interfaces.http import IHTTPRequest
+@adapter(IHTTPRequest)
@implementer(IUserPreferredCharsets)
class Utf8PreferredCharsets:
"""An IUserPreferredCharsets which always chooses utf-8."""
- adapts(IHTTPRequest)
-
def __init__(self, request):
self.request = request
=== modified file 'lib/lp/soyuz/model/livefsbuildbehaviour.py'
--- lib/lp/soyuz/model/livefsbuildbehaviour.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/livefsbuildbehaviour.py 2015-07-09 12:29:31 +0000
@@ -11,7 +11,7 @@
'LiveFSBuildBehaviour',
]
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from zope.security.proxy import removeSecurityProxy
@@ -31,12 +31,11 @@
from lp.soyuz.interfaces.livefsbuild import ILiveFSBuild
+@adapter(ILiveFSBuild)
@implementer(IBuildFarmJobBehaviour)
class LiveFSBuildBehaviour(BuildFarmJobBehaviourBase):
"""Dispatches `LiveFSBuild` jobs to slaves."""
- adapts(ILiveFSBuild)
-
def getLogFileName(self):
das = self.build.distro_arch_series
archname = das.architecturetag
=== modified file 'lib/lp/testing/tests/test_fixture.py'
--- lib/lp/testing/tests/test_fixture.py 2015-07-08 16:05:11 +0000
+++ lib/lp/testing/tests/test_fixture.py 2015-07-09 12:29:31 +0000
@@ -12,7 +12,7 @@
from storm.exceptions import DisconnectionError
import transaction
from zope.component import (
- adapts,
+ adapter,
ComponentLookupError,
getGlobalSiteManager,
queryAdapter,
@@ -69,11 +69,10 @@
pass
+@adapter(IFoo)
@implementer(IBar)
class FooToBar:
- adapts(IFoo)
-
def __init__(self, foo):
self.foo = foo
@@ -90,9 +89,9 @@
self.assertIs(None, queryAdapter(context, IBar))
with ZopeAdapterFixture(FooToBar):
# Now there is an adapter from Foo to Bar.
- adapter = queryAdapter(context, IBar)
- self.assertIsNot(None, adapter)
- self.assertIsInstance(adapter, FooToBar)
+ bar_adapter = queryAdapter(context, IBar)
+ self.assertIsNot(None, bar_adapter)
+ self.assertIsInstance(bar_adapter, FooToBar)
# The adapter is no longer registered.
self.assertIs(None, queryAdapter(context, IBar))
=== modified file 'lib/lp/testopenid/adapters/openid.py'
--- lib/lp/testopenid/adapters/openid.py 2015-07-08 16:05:11 +0000
+++ lib/lp/testopenid/adapters/openid.py 2015-07-09 12:29:31 +0000
@@ -9,7 +9,7 @@
'TestOpenIDPersistentIdentity',
]
-from zope.component import adapts
+from zope.component import adapter
from zope.interface import implementer
from lp.services.identity.interfaces.account import IAccount
@@ -18,12 +18,11 @@
from lp.testopenid.interfaces.server import ITestOpenIDPersistentIdentity
+@adapter(IAccount)
@implementer(ITestOpenIDPersistentIdentity)
class TestOpenIDPersistentIdentity(OpenIDPersistentIdentity):
"""See `IOpenIDPersistentIdentity`."""
- adapts(IAccount)
-
@property
def openid_identity_url(self):
"""See `IOpenIDPersistentIdentity`."""
=== modified file 'lib/lp/translations/model/translationsperson.py'
--- lib/lp/translations/model/translationsperson.py 2015-07-08 16:05:11 +0000
+++ lib/lp/translations/model/translationsperson.py 2015-07-09 12:29:31 +0000
@@ -20,7 +20,7 @@
from storm.info import ClassAlias
from storm.store import Store
from zope.component import (
- adapts,
+ adapter,
getUtility,
)
from zope.interface import implementer
@@ -55,10 +55,9 @@
@implementer(ITranslationsPerson)
+@adapter(IPerson)
class TranslationsPerson:
"""See `ITranslationsPerson`."""
- adapts(IPerson)
-
def __init__(self, person):
self.person = person
=== modified file 'utilities/list-pages'
--- utilities/list-pages 2015-07-08 16:05:11 +0000
+++ utilities/list-pages 2015-07-09 12:29:31 +0000
@@ -49,7 +49,7 @@
from zope.app.testing.functional import FunctionalTestSetup
from zope.browserpage.simpleviewclass import simple
-from zope.component import adapts, getGlobalSiteManager
+from zope.component import adapter, getGlobalSiteManager
from zope.interface import directlyProvides, implementer
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
@@ -72,21 +72,21 @@
FunctionalTestSetup(os.path.join(ROOT, 'zcml', 'webapp.zcml')).setUp()
-def is_page_adapter(adapter):
- """Is 'adapter' a page adapter?
+def is_page_adapter(a):
+ """Is 'a' a page adapter?
We figure this out by checking to see whether it is adapting from
IDefaultBrowserLayer or one of its subclasses.
"""
- for interface in adapter.required:
+ for interface in a.required:
if issubclass(interface, IDefaultBrowserLayer):
return True
return False
-def get_view(adapter):
- """Get the view factory associated with 'adapter'."""
- return adapter.factory
+def get_view(a):
+ """Get the view factory associated with the adapter 'a'."""
+ return a.factory
def get_template_filename(view):
@@ -98,14 +98,14 @@
return os.path.abspath(filename)
-def has_page_title(adapter):
- """Does 'adapter' have a page title?
+def has_page_title(a):
+ """Does 'a' have a page title?
- We use this to tell if 'adapter' is indeed an adapter for rendering an
- entire page. The theory goes that if there's a page title associated with
+ We use this to tell if 'a' is indeed an adapter for rendering an entire
+ page. The theory goes that if there's a page title associated with
something, then it's a page.
"""
- view = get_view(adapter)
+ view = get_view(a)
marker = object()
template = get_template_filename(view)
if template is None:
@@ -215,9 +215,8 @@
@implementer(ICanonicalUrlData)
+@adapter(object)
class DefaultCanonicalUrlData(object):
- adapts(object)
-
def __init__(self, name):
self.path = '[[%s]]' % (name,)
self.rootsite = None
@@ -243,8 +242,8 @@
load_zcml()
gsm = getGlobalSiteManager()
gsm.registerAdapter(DefaultCanonicalUrlData)
- for adapter in iter_page_adapters():
- print format_page_adapter(adapter)
+ for a in iter_page_adapters():
+ print format_page_adapter(a)
if __name__ == '__main__':
Follow ups