> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>
> It makes sense to subclass the type directly if I'm not messing with
> result or bind values. This works:
>
> class StringEnum(types.Enum):
> def __init__(self, *args, **kwargs):
> super(StringEnum, self).__init__(*args, native_enum=False,
> **kwargs)
> self.length = 255
>
> I'm still curious why the TypeDecorator I pasted previously doesn't
> work though. The superconstructor does the self.impl =
> self.__class__.impl(...) anyway so I figured this was the better
> approach than calling self.impl = Enum(...).
its pulling off the "types.Enum" callable from self.__class__ (which actually seems unnecessary here, self.impl should be fine), then calling that with the given arguments. So it should be setting up the native_enum=False part at least. The length attribute though would need to be set on impl. There's no reason we can't make "length" an actual argument of Enum, though, just to help with this kind of thing (I'm assuming that you're planning on adding additional elements to the enum in the future and you don't want to have to alter the column, correct ?).