Re: [sqlalchemy] Re: DeclarativeBase and multiple inheritance - a better solution

2009-12-19 Thread Michael Bayer
Hey guys - I forgot about the really obvious way to do this - class decorators: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() def common_columns(cls): cls.created_at = Column(DateTime,

[sqlalchemy] Re: DeclarativeBase and multiple inheritance

2009-12-17 Thread Daishy
Hi again, I took the approach with creating a Mixin with 4 staticmethods and call them in each of my models, which works quite good. But now i face another, i think related, problem. i get the following columns produced: created_by_id = Column(Integer, ForeignKey('worker.id', onupdate=cascade,

Re: [sqlalchemy] Re: DeclarativeBase and multiple inheritance

2009-12-17 Thread Michael Bayer
On Dec 17, 2009, at 2:35 PM, Daishy wrote: Hi again, I took the approach with creating a Mixin with 4 staticmethods and call them in each of my models, which works quite good. But now i face another, i think related, problem. i get the following columns produced: created_by_id =

[sqlalchemy] Re: DeclarativeBase and multiple inheritance

2009-12-14 Thread Daishy
Hi, I think you are right, messing with the metaclass for 4 columns is not really what i want :) Instead i will use your approach. Put those Columns in the function within the mixin along with all other functions and then call them within the column-definition. Thanks for fast answer! Greetings,