diff --git a/CHANGES.rst b/CHANGES.rst index 795abf2..fb3545b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ New features: Bug fixes: -- *add item here* +- Use zope.interface decorator. + [gforcada] 1.3.15 (2016-05-25) diff --git a/plone/app/querystring/indexmodifiers/query_index_modifiers.py b/plone/app/querystring/indexmodifiers/query_index_modifiers.py index bc03efb..d0fcf1d 100644 --- a/plone/app/querystring/indexmodifiers/query_index_modifiers.py +++ b/plone/app/querystring/indexmodifiers/query_index_modifiers.py @@ -1,9 +1,10 @@ # -*- coding: utf8 -*- from dateutil.parser import parse from plone.app.querystring.interfaces import IParsedQueryIndexModifier -from zope.interface import implements +from zope.interface import implementer +@implementer(IParsedQueryIndexModifier) class Subject(object): """ @@ -17,8 +18,6 @@ class Subject(object): be removed. """ - implements(IParsedQueryIndexModifier) - def __call__(self, value): query = value['query'] # query can be a unicode string or a list of unicode strings. @@ -42,6 +41,7 @@ def __call__(self, value): return ('Subject', value) +@implementer(IParsedQueryIndexModifier) class base(object): """ @@ -49,8 +49,6 @@ class base(object): see Products.PluginIndexes.DateIndex.DateIndex.DateIndex._convert function """ - implements(IParsedQueryIndexModifier) - def __call__(self, value): query = value['query'] if isinstance(query, unicode): diff --git a/plone/app/querystring/tests/index_testmodifier.py b/plone/app/querystring/tests/index_testmodifier.py index daa87fe..a36c267 100644 --- a/plone/app/querystring/tests/index_testmodifier.py +++ b/plone/app/querystring/tests/index_testmodifier.py @@ -1,35 +1,32 @@ # -*- coding: utf8 -*- -from zope.interface import implements +from zope.interface import implementer from plone.app.querystring.interfaces import IParsedQueryIndexModifier +@implementer(IParsedQueryIndexModifier) class SimpleFooIndexModifier(object): """Test simple index modifier that do nothing""" - implements(IParsedQueryIndexModifier) - def __call__(self, value): raise Exception("SimpleFooIndexModifier has been called!") +@implementer(IParsedQueryIndexModifier) class TitleFooIndexModifier(object): """Test index modifier that check always Foo""" - implements(IParsedQueryIndexModifier) - def __call__(self, value): return ('Title', 'Foo') +@implementer(IParsedQueryIndexModifier) class AbstractToDescriptionIndexModifier(object): """ Test index modifier that translate "Abstract" to Description index but where value do not count letter "e" """ - implements(IParsedQueryIndexModifier) - def __call__(self, value): value['query'] = value['query'].replace('e', '') return ('Description', value) diff --git a/plone/app/querystring/tests/testQueryParser.py b/plone/app/querystring/tests/testQueryParser.py index 809bf49..bf05871 100644 --- a/plone/app/querystring/tests/testQueryParser.py +++ b/plone/app/querystring/tests/testQueryParser.py @@ -12,7 +12,7 @@ NOT_INSTALLED_PLONEAPPQUERYSTRING_INTEGRATION_TESTING from zope.component import getGlobalSiteManager -from zope.interface.declarations import implements +from zope.interface import implementer import unittest2 as unittest @@ -74,8 +74,8 @@ class MockSiteProperties(object): navtree_properties = MockNavtreeProperties() +@implementer(INavigationRoot, IPloneSiteRoot) class MockSite(object): - implements(INavigationRoot, IPloneSiteRoot) def __init__(self, portal_membership=None): self.reference_catalog = MockCatalog() @@ -88,8 +88,9 @@ def getPhysicalPath(self): return ["", MOCK_SITE_ID] +@implementer(INavigationRoot) class MockNavRoot(MockObject): - implements(INavigationRoot) + pass class MockUser(object): diff --git a/plone/app/querystring/tests/testRegistryReader.py b/plone/app/querystring/tests/testRegistryReader.py index 6db9597..e0f7ba0 100644 --- a/plone/app/querystring/tests/testRegistryReader.py +++ b/plone/app/querystring/tests/testRegistryReader.py @@ -1,7 +1,7 @@ from plone.registry.interfaces import IRegistry from plone.registry import Registry from zope.component import getGlobalSiteManager -from zope.interface import implements +from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleVocabulary @@ -14,8 +14,8 @@ import unittest2 as unittest +@implementer(IVocabularyFactory) class TestVocabulary(object): - implements(IVocabularyFactory) def __call__(self, context): return SimpleVocabulary([