Is it possible to make a generalized declarative mixin class that abstracts away all of the syntax of inheritance? I've seen examples that set up the __mapper_args__ but not the discriminator column, and examples that set up the discriminator column but not the __mapper_args__, but none with both.
This is roughly how I imagine it should work, but when I tried this, rows were created with null values for the discriminator. A full example is here: https://gist.github.com/797893 class PolymorphicMixin(object): @declared_attr def discriminator(cls): if Base in cls.__bases__: return Column('discriminator', types.String(50)) for b in cls.__bases__: if hasattr(b, 'discriminator'): return b.discriminator @declared_attr def __mapper_args__(cls): ret = {'polymorphic_identity': cls.__name__} if Base in cls.__bases__: ret['polymorphic_on'] = PolymorphicMixin.discriminator return ret Thanks, Scott -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.