[Chandler-dev] Re: Defining a sort order for schema.Enumerations
Phillip J. Eby
pje at telecommunity.com
Tue Jun 20 09:38:52 PDT 2006
At 09:25 AM 6/20/2006 -0700, Bryan Stearns wrote:
>Thanks, Phillip - but now I'm reconsidering: it seemed a tiny bit bad to
>let the user-interface-ness of sort behavior creep into the schema
>mechanism, but now I'm realizing there's another bit of UI-ness needed:
>the (i18n-able) text labels to use for these values.
>
>The simplest approach I can imagine would be to continue in this direction
>and allow a "labels" option on the schema.Enumeration subclass, eg:
>class TriageEnum(schema.Enumeration):
> schema.kindInfo(displayName=_(u"Triage Status Enum"))
> values = "now", "later", "done"
> labels = _(u"Now"), _(u"Later"), _(u"Done")
>
>(I know this requires changing the "you can only have 'values' on
>Enumerations" doc and enforcement, but that's easy. The alternative to
>this would be to put the value-to-label mapping in an attribute editor,
>which would certainly work, but this seems simpler than requiring an
>attribute editor subclass per enumeration.)
How about this instead:
values = dict(
now = (1, _('Now')),
later = (2, _('Later')),
done = (3, _('Done')),
)
More information about the chandler-dev
mailing list