On May 6, 2013, at 11:55 AM, Michael Nachtigal <[email protected]> wrote:
> If I have several mapped classes on which I want to have defined some shared > set of methods, e.g., ._todict(), how can I accomplish this (without multiple > inheritance or defining them manually in each class)? > I tried making the classes inherit from a shared parent class, but I receive > errors because that parent class isn't mapped to anything. > > I appreciate any help that anyone can offer. if you're using declarative mapping, you can define common base classes using the __abstract__ flag: http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#abstract other options include an augmented base and mixins: http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#augmenting-the-base > > -- > 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. > > -- 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.
