Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turned items into a property again on all widgets. [master] #52

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.)

Expand All @@ -25,6 +32,8 @@ CHANGES

* added high level integration tests

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


3.2.10 (2016-03-09)
-------------------
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 @@ -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

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