Skip to content

Commit

Permalink
Merge pull request #63 from plone/gforcada-use-zope-decorators
Browse files Browse the repository at this point in the history
Use zope.interface decorator
  • Loading branch information
jensens authored Jul 25, 2016
2 parents 8108366 + 9d09353 commit a358abb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Use zope.interface decorator.
[gforcada]


1.3.15 (2016-05-25)
Expand Down
8 changes: 3 additions & 5 deletions plone/app/querystring/indexmodifiers/query_index_modifiers.py
Original file line number Diff line number Diff line change
@@ -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):

"""
Expand All @@ -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.
Expand All @@ -42,15 +41,14 @@ def __call__(self, value):
return ('Subject', value)


@implementer(IParsedQueryIndexModifier)
class base(object):

"""
DateIndex query modifier
see Products.PluginIndexes.DateIndex.DateIndex.DateIndex._convert function
"""

implements(IParsedQueryIndexModifier)

def __call__(self, value):
query = value['query']
if isinstance(query, unicode):
Expand Down
11 changes: 4 additions & 7 deletions plone/app/querystring/tests/index_testmodifier.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 additions & 3 deletions plone/app/querystring/tests/testQueryParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -88,8 +88,9 @@ def getPhysicalPath(self):
return ["", MOCK_SITE_ID]


@implementer(INavigationRoot)
class MockNavRoot(MockObject):
implements(INavigationRoot)
pass


class MockUser(object):
Expand Down
4 changes: 2 additions & 2 deletions plone/app/querystring/tests/testRegistryReader.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -14,8 +14,8 @@
import unittest2 as unittest


@implementer(IVocabularyFactory)
class TestVocabulary(object):
implements(IVocabularyFactory)

def __call__(self, context):
return SimpleVocabulary([
Expand Down

0 comments on commit a358abb

Please sign in to comment.