Skip to content

Commit

Permalink
Turned items into a property again on all widgets.
Browse files Browse the repository at this point in the history
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 #44
  • Loading branch information
mauritsvanrees committed Sep 16, 2016
1 parent d5e2b5c commit 5401f61
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ CHANGES
3.2.11 (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]

- Removed ``z3c.coverage`` from ``test`` extra. [gforcada, maurits]


Expand Down
3 changes: 2 additions & 1 deletion src/z3c/form/browser/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/browser/checkbox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/z3c/form/browser/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,7 +81,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

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/browser/radio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/z3c/form/browser/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5401f61

Please sign in to comment.