Skip to content

Commit

Permalink
Use zope.interface decorator
Browse files Browse the repository at this point in the history
This not only makes code more pleasent to read,
but also makes the code python 3 compatible
(while maintaining python 2 compatibility).
  • Loading branch information
gforcada committed Jul 5, 2016
1 parent a9616d7 commit 251a042
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Fixes:
- Update setup.py url to point to github.
[esteele]

- Use zope.interface decorator.
[gforcada]

1.2.9 (2016-02-09)
------------------
Expand Down
8 changes: 4 additions & 4 deletions plone/formwidget/autocomplete/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from z3c.form import form, button, field
from z3c.formwidget.query.interfaces import IQuerySource
from zope.component import adapts
from zope.interface import Interface, implements
from zope.interface import Interface, implementer
from zope import schema
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.vocabulary import SimpleVocabulary
Expand All @@ -12,8 +12,8 @@
from plone.formwidget.autocomplete import AutocompleteMultiFieldWidget


@implementer(IQuerySource)
class KeywordSource(object):
implements(IQuerySource)

def __init__(self, context):
self.context = context
Expand Down Expand Up @@ -42,8 +42,8 @@ def search(self, query_string):
return [self.getTerm(kw) for kw in self.keywords if q in kw.lower()]


@implementer(IContextSourceBinder)
class KeywordSourceBinder(object):
implements(IContextSourceBinder)

def __call__(self, context):
return KeywordSource(context)
Expand All @@ -58,8 +58,8 @@ class ITestForm(Interface):
title=u"Multiple", source=KeywordSourceBinder()), required=False)


@implementer(ITestForm)
class TestAdapter(object):
implements(ITestForm)
adapts(Interface)

def __init__(self, context):
Expand Down
4 changes: 2 additions & 2 deletions plone/formwidget/autocomplete/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import z3c.form.util
from z3c.formwidget.query.widget import QuerySourceRadioWidget
from z3c.formwidget.query.widget import QuerySourceCheckboxWidget
from zope.interface import implementsOnly, implementer
from zope.interface import implementer_only, implementer

from plone.formwidget.autocomplete.interfaces import IAutocompleteWidget

Expand Down Expand Up @@ -68,8 +68,8 @@ def __call__(self):
for t in sorted(terms, key=lambda t: t.title)])


@implementer_only(IAutocompleteWidget)
class AutocompleteBase(Explicit):
implementsOnly(IAutocompleteWidget)

security = ClassSecurityInfo()
security.declareObjectPublic()
Expand Down

0 comments on commit 251a042

Please sign in to comment.