The following class works on 0.8.0b2 but not 0.8.0 final:
> class EnumWrapper(SchemaType, TypeDecorator):
> def __init__(self, cls):
> kwargs = {'name': cls.__name__.lower()}
> self.impl = Enum(*(obj.key for obj in cls.values), **kwargs)
> self.wrapped = cls
>
> def _set_table(self, table, column):
> self.impl._set_table(table, column)
>
> def process_bind_param(self, value, dialect):
> if value is None:
> return None
> if isinstance(value, self.wrapped):
> return value.key
> elif isinstance(value, str):
> if value not in self.wrapped.symbols:
> raise TypeError('No such enum value in %s: %s' %
> (self.wrapped.__name__, value))
> return value
> raise TypeError('Expected %s, got %s instead' % (self.wrapped,
> type(value)))
>
> def process_result_value(self, value, dialect):
> return getattr(self.wrapped, value) if value is not None else None
>
The error message ("TypeError: __init__() got an unexpected keyword
argument 'schema'") originates from types.py, line 1886.
Is inheriting from SchemaType still necessary? That is what seems to break
things on 0.8.0 final.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.