Wiadomość napisana przez Tom Evans w dniu 4 kwi 2012, o godz. 18:40:
> 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.
Thanks for your feedback. Do model and form field definitions say that as well?
It's true that I could have block users from mutating the value but "we're all
consenting adults here", right?
> There is no easy way by inspecting the code to see what choice a value
> of 7 equates to any-more.
True, the same goes for spotting errors with manual numbering when there are
many values.
> 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.
It's a matter of aesthetics and as such it's totally subjective. I made the
values start from 1 so that the first Choice.Group can have value 0 and not -1
which looks ugly.
> 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.
I can't see how they have to.
> If I had a vote, I'd be strongly -1 on
> any proposal with this sort of grouping, it seems dangerous and wrong.
Can you elaborate on what is dangerous about them?
> 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.
Using code in my proposal:
>>> class Gender(Choices):
... m = Choice("male")
... f = Choice("female")
... n = Choice("not specified")
...
>>> Gender(item=lambda c: (c.name, c.desc))
[(u'm', u'male'), (u'f', u'female'), (u'n', u'not specified')]
--
Best regards,
Łukasz Langa
Senior Systems Architecture Engineer
IT Infrastructure Department
Grupa Allegro Sp. z o.o.
http://lukasz.langa.pl/
+48 791 080 144
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.