[Chandler-dev] Re: Defining a sort order for schema.Enumerations
Phillip J. Eby
pje at telecommunity.com
Mon Jun 19 17:22:35 PDT 2006
At 03:58 PM 6/19/2006 -0700, Bryan Stearns wrote:
>class EnumerationClass(Activator):
> def __init__(cls,name,bases,cdict):
> [...]
> cls.ordering = dict((v, i) for (i, v) in enumerate(cls.values))
>
>Or can you suggest a better way to accomplish this?
Actually, this seems fine to me. In your shoes I probably would've just
changed the enumeration names to "01 now", "02 later", "03 done", which is
a cheap hack of course but very easy to do. :)
However, the above seems like a perfectly fine way of doing it. If you'd
like to add it officially, though, you need to update
application/parcel-schema-guide.txt to explain the feature by example in
the section on enumerations, which will as a side effect provide a test for
the feature. Make sure that you put an error in your example to verify
that the example is in fact run when you run the tests. (The corresponding
test .py file is application/tests/TestSchema.py.)
More information about the chandler-dev
mailing list