2012/4/3 Łukasz Langa <luk...@langa.pl>: > A nice HTML rendering of this proposal is available at: > http://lukasz.langa.pl/2/upgrading-choices-machinery-django/
Disclaimer: all my code currently looks like 'Way 3'. In general, I like it. There are a few things I don't like in it: The class definition grates. When we say things like: class Gender(Choices): male = Choice("male") That says to me that Gender.male is mutable. Ick. There is no easy way by inspecting the code to see what choice a value of 7 equates to any-more. Do the choices start from 0 or do they start from 1, as inferred by the examples (Why? What is wrong with 0?). Repetition isn't good, but ambiguity is worse. I don't like the grouping at all. Grouping under the old system was clean and simple, it didn't require magic arguments, groups didn't require that all options are contiguous in a single range. This grouping system just seems destined for data loss/confusion. If I want to split a group in two, the enums in the new group change values! That is not a good approach, and was not necessary with the old system. This grouping system cannot logically arrange the options into groups, since it relies on them being attributes of the class, and so you need to invent a way of grouping. If I had a vote, I'd be strongly -1 on any proposal with this sort of grouping, it seems dangerous and wrong. Finally, the proposal seems to concentrate solely on choices as an enum. The proposal completely ignores that choices can be almost any kind of value, eg: MALE="m" FEMALE="f" UNKNOWN="?" GENDER_CHOICES = ( (MALE, "Male"), (FEMALE, "Female"), (UNKNOWN, "Unknown"), ) this would be an entirely appropriate choices for a CharField. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.