DBEnumeratedType's default sort_order should follow its items' values

Bug #129192 reported by Eleanor Berger
2
Affects Status Importance Assigned to Milestone
lazr.enum
Triaged
Low
Unassigned

Bug Description

canonical.lazr.enum.DBEnumeratedType provides a great new way to implement enumerated types with values that also double as zope vocabularies.

The default sort_order for DBEnumeratedType seems to be based on the order of the assignment of the attributes, but in almost all cases we'd expect to sort by the value of the DBItems. As a further complication, it is impossible, due to the way the implementation uses the metaclass protocol, to provide a dynamic implementation of sort_order which inspects the DBItems, since at the time sort_order is called for the first time the class still doesn't provide the iterator over those items.

Changed in launchpad:
assignee: nobody → thumper
Revision history for this message
Tim Penhey (thumper) wrote :

You have three choices here:

1) Re-order the declaration order of the DBItems
2) Add a sort_order member
3) Derive from the schema to change the order if more than one order is needed

Revision history for this message
Eleanor Berger (intellectronica) wrote :

> 1) Re-order the declaration order of the DBItems

Doesn't work for derived classes that add new items - the new items will be appended at the end of the existing order list.

> 2) Add a sort_order member

Of course, but it would be nice to be able to use a property and build the sort order dynamically.

> 3) Derive from the schema to change the order if more than one order is needed

Sure, but you'd still have to specify all the items explicitly.

Tim Penhey (thumper)
Changed in launchpad-foundations:
assignee: thumper → nobody
Curtis Hovey (sinzui)
Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
visibility: private → public
affects: launchpad → lazr.enum
Revision history for this message
Tim Penhey (thumper) wrote : Re: [Bug 129192] [NEW] DBEnumeratedType's default sort_order should follow its items' values

I think that this should be implemented by allowing a function to sort the
items.

This could then also be used to provide a function to provide an alphabetical
sort order.

Tim

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.