From 0acbe0e84350ce2b5fdda3555da2ee321bbfc72b Mon Sep 17 00:00:00 2001 From: gforcada Date: Thu, 7 Jul 2016 00:58:49 +0200 Subject: [PATCH] [fc] Repository: plone.formwidget.datetime Branch: refs/heads/master Date: 2016-07-05T23:16:07+02:00 Author: Gil Forcada (gforcada) Commit: https://github.com/plone/plone.formwidget.datetime/commit/64123d645cc11d89fbd2c62f5a64d79e3d77b471 Use zope.interface decorator This not only makes code more pleasent to read, but also makes the code python 3 compatible (while maintaining python 2 compatibility). Files changed: M CHANGES.rst M plone/formwidget/datetime/setuphandlers.py M plone/formwidget/datetime/z3cform/widget.py Repository: plone.formwidget.datetime Branch: refs/heads/master Date: 2016-07-07T00:58:49+02:00 Author: Gil Forcada Codinachs (gforcada) Commit: https://github.com/plone/plone.formwidget.datetime/commit/5b7c123ca7cdfa3c40fc77a6457abaae88ade4f2 Merge pull request #18 from plone/gforcada-use-zope-decorators Use zope.interface decorator Files changed: M CHANGES.rst M plone/formwidget/datetime/setuphandlers.py M plone/formwidget/datetime/z3cform/widget.py --- last_commit.txt | 318 ++++++++++++++++++++++++------------------------ 1 file changed, 157 insertions(+), 161 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index 09b4e8d0c0..5fa54fdb8e 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,10 +1,10 @@ -Repository: plone.formwidget.recurrence +Repository: plone.formwidget.datetime Branch: refs/heads/master -Date: 2016-07-05T23:16:29+02:00 +Date: 2016-07-05T23:16:07+02:00 Author: Gil Forcada (gforcada) -Commit: https://github.com/plone/plone.formwidget.recurrence/commit/b5892789d973e367142c3857f4728e55b4446b8d +Commit: https://github.com/plone/plone.formwidget.datetime/commit/64123d645cc11d89fbd2c62f5a64d79e3d77b471 Use zope.interface decorator @@ -14,209 +14,205 @@ but also makes the code python 3 compatible Files changed: M CHANGES.rst -M plone/formwidget/recurrence/at/widget.py -M plone/formwidget/recurrence/tests/test_z3cwidget.py -M plone/formwidget/recurrence/z3cform/field.py -M plone/formwidget/recurrence/z3cform/widget.py +M plone/formwidget/datetime/setuphandlers.py +M plone/formwidget/datetime/z3cform/widget.py diff --git a/CHANGES.rst b/CHANGES.rst -index 93058b6..6e6d33f 100644 +index f91454b..95caa5d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -14,7 +14,8 @@ New features: +@@ -12,6 +12,8 @@ Fixes: - Bug fixes: + - Marked in setup.py as also compatible with Plone 4.3, next to 5.0. [maurits] --- *add item here* +- Use zope.interface decorator. + [gforcada] - - 2.1.0 (2016-05-09) -diff --git a/plone/formwidget/recurrence/at/widget.py b/plone/formwidget/recurrence/at/widget.py -index 69afc9f..cbd902c 100644 ---- a/plone/formwidget/recurrence/at/widget.py -+++ b/plone/formwidget/recurrence/at/widget.py -@@ -7,7 +7,7 @@ - from Products.validation.interfaces.IValidator import IValidator - from dateutil import rrule - from zope.component.hooks import getSite --from zope.interface import implements -+from zope.interface import implementer - from plone.formwidget.recurrence.browser.i18n import translations - - import json -@@ -62,9 +62,8 @@ def get_pattern_options(self): - used_for=('plone.app.event.recurrence.RecurrenceField',)) - - -+@implementer(IValidator) - class RecurrenceValidator(object): -- # TODO: tests -- implements(IValidator) - - def __init__(self, name): - self.name = name -diff --git a/plone/formwidget/recurrence/tests/test_z3cwidget.py b/plone/formwidget/recurrence/tests/test_z3cwidget.py -index f2fe28a..36d7b7c 100644 ---- a/plone/formwidget/recurrence/tests/test_z3cwidget.py -+++ b/plone/formwidget/recurrence/tests/test_z3cwidget.py -@@ -15,8 +15,8 @@ class ITestForm(zope.interface.Interface): - day = zope.schema.Date(title=u'Day', required=True) - - -+@zope.interface.implementer(ITestForm) - class TestForm(SimpleItem): -- zope.interface.implements(ITestForm) - recurrence = FieldProperty(ITestForm['recurrence']) - day = FieldProperty(ITestForm['day']) - -diff --git a/plone/formwidget/recurrence/z3cform/field.py b/plone/formwidget/recurrence/z3cform/field.py -index 743204e..93529b0 100644 ---- a/plone/formwidget/recurrence/z3cform/field.py -+++ b/plone/formwidget/recurrence/z3cform/field.py -@@ -1,7 +1,8 @@ - from zope import schema + 1.3 (2016-02-11) + ---------------- +diff --git a/plone/formwidget/datetime/setuphandlers.py b/plone/formwidget/datetime/setuphandlers.py +index 9eb63e3..b936267 100644 +--- a/plone/formwidget/datetime/setuphandlers.py ++++ b/plone/formwidget/datetime/setuphandlers.py +@@ -1,9 +1,9 @@ -from zope.interface import implements +from zope.interface import implementer - from plone.formwidget.recurrence.z3cform.interfaces import IRecurrenceField - - -+@implementer(IRecurrenceField) - class RecurrenceField(schema.Text): -- implements(IRecurrenceField) -+ pass -diff --git a/plone/formwidget/recurrence/z3cform/widget.py b/plone/formwidget/recurrence/z3cform/widget.py -index 85b46d5..13957a1 100644 ---- a/plone/formwidget/recurrence/z3cform/widget.py -+++ b/plone/formwidget/recurrence/z3cform/widget.py -@@ -8,15 +8,15 @@ + 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 +diff --git a/plone/formwidget/datetime/z3cform/widget.py b/plone/formwidget/datetime/z3cform/widget.py +index 0300440..2882362 100644 +--- a/plone/formwidget/datetime/z3cform/widget.py ++++ b/plone/formwidget/datetime/z3cform/widget.py +@@ -11,7 +11,7 @@ from z3c.form.widget import FieldWidget from zope.component import adapter - from zope.component.hooks import getSite --from zope.interface import implementsOnly, implementer -+from zope.interface import implementer_only, implementer - from zope.traversing.browser import absoluteURL + 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 + + +@@ -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) +@@ -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 +@@ -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) - import json + def extract(self, default=NOVALUE): + day = self.request.get(self.name + '-day', default) +@@ -155,9 +155,9 @@ def MonthYearFieldWidget(field, request): + return FieldWidget(field, MonthYearWidget(request)) -+@implementer_only(IRecurrenceWidget) - class RecurrenceWidget(TextAreaWidget): - """Recurrence widget implementation.""" -- implementsOnly(IRecurrenceWidget) ++@implementer_only(IYearWidget) + class YearWidget(base.AbstractYearWidget, AbstractDXDateWidget): + """ Year widget """ +- implementsOnly(IYearWidget) - klass = u'recurrence-widget' - value = u'' + def extract(self, default=NOVALUE): + day = self.request.get(self.name + '-day', default) -Repository: plone.formwidget.recurrence +Repository: plone.formwidget.datetime Branch: refs/heads/master -Date: 2016-07-07T00:58:17+02:00 +Date: 2016-07-07T00:58:49+02:00 Author: Gil Forcada Codinachs (gforcada) -Commit: https://github.com/plone/plone.formwidget.recurrence/commit/93a5f1c83eae2c7d394640c56517752aa8a833db +Commit: https://github.com/plone/plone.formwidget.datetime/commit/5b7c123ca7cdfa3c40fc77a6457abaae88ade4f2 -Merge pull request #20 from plone/gforcada-use-zope-decorators +Merge pull request #18 from plone/gforcada-use-zope-decorators Use zope.interface decorator Files changed: M CHANGES.rst -M plone/formwidget/recurrence/at/widget.py -M plone/formwidget/recurrence/tests/test_z3cwidget.py -M plone/formwidget/recurrence/z3cform/field.py -M plone/formwidget/recurrence/z3cform/widget.py +M plone/formwidget/datetime/setuphandlers.py +M plone/formwidget/datetime/z3cform/widget.py diff --git a/CHANGES.rst b/CHANGES.rst -index 93058b6..6e6d33f 100644 +index f91454b..95caa5d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -14,7 +14,8 @@ New features: +@@ -12,6 +12,8 @@ Fixes: - Bug fixes: + - Marked in setup.py as also compatible with Plone 4.3, next to 5.0. [maurits] --- *add item here* +- Use zope.interface decorator. + [gforcada] - - 2.1.0 (2016-05-09) -diff --git a/plone/formwidget/recurrence/at/widget.py b/plone/formwidget/recurrence/at/widget.py -index 69afc9f..cbd902c 100644 ---- a/plone/formwidget/recurrence/at/widget.py -+++ b/plone/formwidget/recurrence/at/widget.py -@@ -7,7 +7,7 @@ - from Products.validation.interfaces.IValidator import IValidator - from dateutil import rrule - from zope.component.hooks import getSite --from zope.interface import implements -+from zope.interface import implementer - from plone.formwidget.recurrence.browser.i18n import translations - - import json -@@ -62,9 +62,8 @@ def get_pattern_options(self): - used_for=('plone.app.event.recurrence.RecurrenceField',)) - - -+@implementer(IValidator) - class RecurrenceValidator(object): -- # TODO: tests -- implements(IValidator) - - def __init__(self, name): - self.name = name -diff --git a/plone/formwidget/recurrence/tests/test_z3cwidget.py b/plone/formwidget/recurrence/tests/test_z3cwidget.py -index f2fe28a..36d7b7c 100644 ---- a/plone/formwidget/recurrence/tests/test_z3cwidget.py -+++ b/plone/formwidget/recurrence/tests/test_z3cwidget.py -@@ -15,8 +15,8 @@ class ITestForm(zope.interface.Interface): - day = zope.schema.Date(title=u'Day', required=True) - - -+@zope.interface.implementer(ITestForm) - class TestForm(SimpleItem): -- zope.interface.implements(ITestForm) - recurrence = FieldProperty(ITestForm['recurrence']) - day = FieldProperty(ITestForm['day']) - -diff --git a/plone/formwidget/recurrence/z3cform/field.py b/plone/formwidget/recurrence/z3cform/field.py -index 743204e..93529b0 100644 ---- a/plone/formwidget/recurrence/z3cform/field.py -+++ b/plone/formwidget/recurrence/z3cform/field.py -@@ -1,7 +1,8 @@ - from zope import schema + 1.3 (2016-02-11) + ---------------- +diff --git a/plone/formwidget/datetime/setuphandlers.py b/plone/formwidget/datetime/setuphandlers.py +index 9eb63e3..b936267 100644 +--- a/plone/formwidget/datetime/setuphandlers.py ++++ b/plone/formwidget/datetime/setuphandlers.py +@@ -1,9 +1,9 @@ -from zope.interface import implements +from zope.interface import implementer - from plone.formwidget.recurrence.z3cform.interfaces import IRecurrenceField - - -+@implementer(IRecurrenceField) - class RecurrenceField(schema.Text): -- implements(IRecurrenceField) -+ pass -diff --git a/plone/formwidget/recurrence/z3cform/widget.py b/plone/formwidget/recurrence/z3cform/widget.py -index 85b46d5..13957a1 100644 ---- a/plone/formwidget/recurrence/z3cform/widget.py -+++ b/plone/formwidget/recurrence/z3cform/widget.py -@@ -8,15 +8,15 @@ + 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 +diff --git a/plone/formwidget/datetime/z3cform/widget.py b/plone/formwidget/datetime/z3cform/widget.py +index 0300440..2882362 100644 +--- a/plone/formwidget/datetime/z3cform/widget.py ++++ b/plone/formwidget/datetime/z3cform/widget.py +@@ -11,7 +11,7 @@ from z3c.form.widget import FieldWidget from zope.component import adapter - from zope.component.hooks import getSite --from zope.interface import implementsOnly, implementer -+from zope.interface import implementer_only, implementer - from zope.traversing.browser import absoluteURL + 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 + + +@@ -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) +@@ -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 +@@ -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) - import json + def extract(self, default=NOVALUE): + day = self.request.get(self.name + '-day', default) +@@ -155,9 +155,9 @@ def MonthYearFieldWidget(field, request): + return FieldWidget(field, MonthYearWidget(request)) -+@implementer_only(IRecurrenceWidget) - class RecurrenceWidget(TextAreaWidget): - """Recurrence widget implementation.""" -- implementsOnly(IRecurrenceWidget) ++@implementer_only(IYearWidget) + class YearWidget(base.AbstractYearWidget, AbstractDXDateWidget): + """ Year widget """ +- implementsOnly(IYearWidget) - klass = u'recurrence-widget' - value = u'' + def extract(self, default=NOVALUE): + day = self.request.get(self.name + '-day', default)