From e258f631c212f5ba4d9f625adf77dcfe91bfb92d Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Fri, 16 Sep 2016 18:31:08 +0200 Subject: [PATCH] Turned `items` into a property again on all widgets. For the select widget it was a method since 2.9.0. For the radio and checkbox widgets it was a method since 3.2.10. For orderedselect and multi it was always a property. Fixes https://github.com/zopefoundation/z3c.form/issues/44 --- CHANGES.txt | 9 +++++++++ src/z3c/form/browser/checkbox.py | 3 ++- src/z3c/form/browser/checkbox.txt | 2 +- src/z3c/form/browser/radio.py | 3 ++- src/z3c/form/browser/radio.txt | 2 +- src/z3c/form/browser/select.py | 3 ++- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 90ab577b..4d93e6a4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,13 @@ CHANGES 3.3.1 (unreleased) ------------------ +- Turned ``items`` into a property again on all widgets. + For the select widget it was a method since 2.9.0. + For the radio and checkbox widgets it was a method since 3.2.10. + For orderedselect and multi it was always a property. + Fixes https://github.com/zopefoundation/z3c.form/issues/44 + [maurits] + - Fix handling of missing terms in collections. (See version 2.9 describing this feature.) @@ -25,6 +32,8 @@ CHANGES * added high level integration tests +- Removed ``z3c.coverage`` from ``test`` extra. [gforcada, maurits] + 3.2.10 (2016-03-09) ------------------- diff --git a/src/z3c/form/browser/checkbox.py b/src/z3c/form/browser/checkbox.py index bbd34acf..c176d973 100644 --- a/src/z3c/form/browser/checkbox.py +++ b/src/z3c/form/browser/checkbox.py @@ -40,6 +40,7 @@ class CheckBoxWidget(widget.HTMLInputWidget, SequenceWidget): def isChecked(self, term): return term.token in self.value + @property def items(self): if self.terms is None: return () @@ -64,7 +65,7 @@ def update(self): def json_data(self): data = super(CheckBoxWidget, self).json_data() - data['options'] = list(self.items()) + data['options'] = list(self.items) data['type'] = 'check' return data diff --git a/src/z3c/form/browser/checkbox.txt b/src/z3c/form/browser/checkbox.txt index 4f56f889..8188bb86 100644 --- a/src/z3c/form/browser/checkbox.txt +++ b/src/z3c/form/browser/checkbox.txt @@ -206,7 +206,7 @@ the value (which is used as a backup label) contains non-ASCII characters: >>> terms = SimpleVocabulary.fromValues([b'yes\012', b'no\243']) >>> widget.terms = terms >>> widget.update() - >>> pprint(list(widget.items())) + >>> pprint(list(widget.items)) [{'checked': False, 'id': 'widget-id-0', 'label': 'yes\n', diff --git a/src/z3c/form/browser/radio.py b/src/z3c/form/browser/radio.py index 683dfc8b..2d02806b 100644 --- a/src/z3c/form/browser/radio.py +++ b/src/z3c/form/browser/radio.py @@ -59,6 +59,7 @@ def renderForValue(self, value): IPageTemplate, name=self.mode + '_single') return template(self, item) + @property def items(self): if self.terms is None: return @@ -81,7 +82,7 @@ def update(self): def json_data(self): data = super(RadioWidget, self).json_data() - data['options'] = list(self.items()) + data['options'] = list(self.items) data['type'] = 'radio' return data diff --git a/src/z3c/form/browser/radio.txt b/src/z3c/form/browser/radio.txt index cdee3192..5b9fc0a0 100644 --- a/src/z3c/form/browser/radio.txt +++ b/src/z3c/form/browser/radio.txt @@ -240,7 +240,7 @@ the value (which is used as a backup label) contains non-ASCII characters: >>> terms = SimpleVocabulary.fromValues([b'yes\012', b'no\243']) >>> widget.terms = terms >>> widget.update() - >>> pprint(list(widget.items())) + >>> pprint(list(widget.items)) [{'checked': False, 'id': 'widget-id-0', 'label': 'yes\n', diff --git a/src/z3c/form/browser/select.py b/src/z3c/form/browser/select.py index aee3f93d..9133eff2 100644 --- a/src/z3c/form/browser/select.py +++ b/src/z3c/form/browser/select.py @@ -51,6 +51,7 @@ def update(self): super(SelectWidget, self).update() widget.addFieldClass(self) + @property def items(self): if self.terms is None: # update() has not been called yet return () @@ -98,7 +99,7 @@ def addItem(idx, term, prefix=''): def json_data(self): data = super(SelectWidget, self).json_data() - data['options'] = self.items() + data['options'] = self.items data['type'] = 'select' return data