MultiSelectWidget configured for ISet but creates list

Bug #98111 reported by Garrett Smith
4
Affects Status Importance Assigned to Milestone
Zope 3
Fix Released
High
Unassigned

Bug Description

This is a bug because the MultiSelectWidget can't be used -- it only shows up for Sets, but causes TypeError because it generates list.

I'm not sure what the solution is. The obvious fix would be to modify MultiSelectWidget to generate sets.Set objects. But it might not be fair to force sets.Set as the data type when the developer wants something else.

The solution might also be to create a concrete Sequence field type and let the user provide the implementation type, whether the sequence is unique, etc. A general purpose sequence widget (or more likely a dispatcher) would implement the correct UI based on the field settings.

Comment from Jim in reply to this issue:
---
It should be useful for a sequence that wants unique values.

I agree that it is not useful as a set widget.
Of course, it should be easy to create a version that does.
Perhaps, in fact, it could alter what it generates based on it's
context.
---

Tags: bug core
Revision history for this message
Stephan Richter (srichter) wrote :

Changes: submitter email, importance (medium => urgent)

Revision history for this message
Stephan Richter (srichter) wrote :

Status: Pending => Resolved

Fixed in revision 29380.

I basically followed Jim's suggestion and look at the AbstractCollection's `_type` attribute to get the correct collection type. If another type of collection field is used, it will always return a list. A test inspecting the output type of `widget.getInputValue()` has been added as a demonstration.

Revision history for this message
LeoRochael (leorochael) wrote :

This issue was not completely fixed. It breaks in the case where the collection is empty. See attached diff for test and fix

Revision history for this message
LeoRochael (leorochael) wrote :

Reopening due to failure in empty collections

Changed in zope3:
status: Fix Released → Confirmed
LeoRochael (leorochael)
Changed in zope3:
status: Confirmed → Fix Committed
Revision history for this message
LeoRochael (leorochael) wrote :

Fix has been incorporated in the last Zope2 (including 2.10) and Zope3 (including 3.3) releases.

Changed in zope3:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.