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 05bab6c commit 64123d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Fixes:

- Marked in setup.py as also compatible with Plone 4.3, next to 5.0. [maurits]

- Use zope.interface decorator.
[gforcada]

1.3 (2016-02-11)
----------------
Expand Down
4 changes: 2 additions & 2 deletions plone/formwidget/datetime/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from zope.interface import implements
from zope.interface import implementer
from Products.CMFPlone.interfaces import INonInstallable


@implementer(INonInstallable)
class HiddenProfiles(object):
implements(INonInstallable)

def getNonInstallableProfiles(self):
"""Prevents profiles, which should not be user-installable from showing
Expand Down
10 changes: 5 additions & 5 deletions plone/formwidget/datetime/z3cform/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from z3c.form.widget import FieldWidget
from zope.component import adapter
from zope.i18n.format import DateTimeParseError
from zope.interface import implementer, implementsOnly
from zope.interface import implementer, implementer_only
from zope.schema.interfaces import IField


Expand Down Expand Up @@ -52,12 +52,12 @@ def update(self):
addFieldClass(self)


@implementer_only(IDateWidget)
class DateWidget(base.AbstractDateWidget, AbstractDXDateWidget):
""" Date widget.
Please note: zope.schema date/datetime field values are python datetime
instances.
"""
implementsOnly(IDateWidget)


@implementer(IFieldWidget)
Expand All @@ -67,9 +67,9 @@ def DateFieldWidget(field, request):
return FieldWidget(field, DateWidget(request))


@implementer_only(IDatetimeWidget)
class DatetimeWidget(base.AbstractDatetimeWidget, AbstractDXDateWidget):
""" DateTime widget """
implementsOnly(IDatetimeWidget)

def extract(self, default=NOVALUE):
# get normal input fields
Expand Down Expand Up @@ -133,9 +133,9 @@ def DatetimeFieldWidget(field, request):
return FieldWidget(field, DatetimeWidget(request))


@implementer_only(IMonthYearWidget)
class MonthYearWidget(base.AbstractMonthYearWidget, AbstractDXDateWidget):
""" Month and year widget """
implementsOnly(IMonthYearWidget)

def extract(self, default=NOVALUE):
day = self.request.get(self.name + '-day', default)
Expand All @@ -155,9 +155,9 @@ def MonthYearFieldWidget(field, request):
return FieldWidget(field, MonthYearWidget(request))


@implementer_only(IYearWidget)
class YearWidget(base.AbstractYearWidget, AbstractDXDateWidget):
""" Year widget """
implementsOnly(IYearWidget)

def extract(self, default=NOVALUE):
day = self.request.get(self.name + '-day', default)
Expand Down

0 comments on commit 64123d6

Please sign in to comment.