OrderedMultiSelectWidget can't handle single selection properly

Bug #98290 reported by Watanabe Katsutoshi
2
Affects Status Importance Assigned to Milestone
Zope 3
Invalid
Critical
Unassigned

Bug Description

# in advance, I apologize my rude english.

OrderedMultiSelectWidget.selected() doesn't seem to work properly.

below is an excerpt from 'itemswidget.py' in 'zope.app.form.browser' package
(cuurent revision of 'itemswidget.py' is 39064)

--
570 def selected(self):
571 """Return a list of tuples (text, value) that are selected."""
572 # Get form values
573 values = self._getFormValue()
574 # Not all content objects must necessarily support the attributes
575 if hasattr(self.context.context, self.context.__name__):
576 # merge in values from content
577 for value in self.context.get(self.context.context):
578 if value not in values:
579 values.append(value)
580
581 terms = [self.vocabulary.getTerm(value)
582 for value in values]
583 return [{'text': self.textForValue(term), 'value': term.token}
584 for term in terms]
--

if 'values' at 573 is a single value like 'abc' not a list,
the sigle value is shredded into meaningless values like 'a' or 'b'.
It results in an exception raised by getTerm() at 581.

I thik it would be a bug.

I'm totally newbie about python and zope3.
If it's not a bug, please forgive me.

regards.

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

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

Revision history for this message
Adam Groszer (agroszer) wrote :

Hi, I'm looking at the problem but unable to recreate the problem.
wata, please drop us a mail how to recreate it.

Selecting a single item in the browser does not hit it.

What I can imagine is, that the context object's property got changed from a list to a string.

Revision history for this message
Christian Theune (ctheune) wrote :

Watanabe, thanks for reporting this bug, however, we need more input as we can't reproduce.

Changed in zope3:
status: Unconfirmed → Needs Info
Revision history for this message
Christian Theune (ctheune) wrote :

I reviewed this again. I don't think it is a bug. The context of an OrderedMultiSelectWidget should always be an iterable, not a single value.

Changed in zope3:
status: Incomplete → Invalid
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.