Ticket #13421 (closed Bug: fixed)

Opened 4 years ago

Last modified 4 years ago

[archetypes.querywidget] getSortedValuesKeys raise AttributeError if vocabulary values are integers

Reported by: frapell Owned by:
Priority: minor Milestone: 4.x
Component: Archetypes Version: 4.2
Keywords: patch Cc:

Description

When specifying a vocabulary for a query field which has integers as values, getSortedValuesKeys explodes, as it assumes always to get string values.

Full trace:

Traceback (most recent call last):
  File "/trabajo/buildout/eggs/unittest2-0.5.1-py2.7.egg/unittest2/case.py", line 340, in run
    testMethod()
  File "/trabajo/plone/archetypes.querywidget/archetypes/querywidget/tests/test_multi_select_widget.py", line 26, in test_sorted_values
    self.assertEqual(view.getSortedValuesKeys(integer_values), [1, 2, 3])
  File "/trabajo/plone/archetypes.querywidget/archetypes/querywidget/views.py", line 77, in getSortedValuesKeys
    return sorted(values.iterkeys(), key = lambda x : x.lower())
  File "/trabajo/plone/archetypes.querywidget/archetypes/querywidget/views.py", line 77, in <lambda>
    return sorted(values.iterkeys(), key = lambda x : x.lower())
AttributeError: 'int' object has no attribute 'lower'

Change History

comment:1 Changed 4 years ago by frapell

Pull request with the fix and tests for it

 https://github.com/plone/archetypes.querywidget/pull/6

comment:2 Changed 4 years ago by kleist

  • Keywords patch added
  • Status changed from new to confirmed
  • Component changed from Unknown to Archetypes

comment:3 Changed 4 years ago by frapell

  • Status changed from confirmed to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.