From 8251e0ebfcabca2b941fe7cd4f33205ee873477d Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Thu, 29 Sep 2016 13:14:41 +0200 Subject: [PATCH] In select widget, accept items as property or method. This avoids breaking on some z3c.form versions. See https://github.com/zopefoundation/z3c.form/issues/44 --- CHANGES.rst | 7 +++++-- plone/app/z3cform/widget.py | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0b192a2a..4ec6b91e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,10 @@ New features: Bug fixes: -- *add item here* +- In select widget, accept items as property or method. + This avoids breaking on some z3c.form versions. + See https://github.com/zopefoundation/z3c.form/issues/44 + [maurits] 2.1.1 (2016-09-16) @@ -75,7 +78,7 @@ Fixes: - Reduce dependency on plone.app.widgets in tests. [thet] -- Enhance test in order to show problem in RelatedItemsWidget with +- Enhance test in order to show problem in RelatedItemsWidget with navigation-roots [jensens] diff --git a/plone/app/z3cform/widget.py b/plone/app/z3cform/widget.py index 5284fab4..42e66ae5 100644 --- a/plone/app/z3cform/widget.py +++ b/plone/app/z3cform/widget.py @@ -270,8 +270,16 @@ def _base_args(self): if not self.required: options['allowClear'] = True + base_items = self.items + if callable(base_items): + # items used to be a property in all widgets, then in the select + # widget it became a method, then in a few others too, but never in + # all, so this was reverted to let it be a property again. Let's + # support both here to avoid breaking on some z3c.form versions. + # See https://github.com/zopefoundation/z3c.form/issues/44 + base_items = base_items() items = [] - for item in self.items(): + for item in base_items: if not isinstance(item['content'], basestring): item['content'] = translate( item['content'],