Re: [sqlalchemy] aliased in mixins

2012-08-01 Thread Sergey Kucheryavski
Thank you very much! On Wednesday, August 1, 2012 4:20:23 PM UTC+2, Michael Bayer wrote: > > oh, sorry, that's a mixin. this combination of variables is not supported > at this time. You need to use an event: > > from sqlalchemy import event > from sqlalchemy.orm import mapper > @event.listens_

Re: [sqlalchemy] aliased in mixins

2012-08-01 Thread Michael Bayer
oh, sorry, that's a mixin. this combination of variables is not supported at this time. You need to use an event: from sqlalchemy import event from sqlalchemy.orm import mapper @event.listens_for(mapper, "mapper_configured") def set_num_children(mapper, cls): if not issubclass(cls, MPTT):

Re: [sqlalchemy] aliased in mixins

2012-08-01 Thread Sergey Kucheryavski
Thanks Michael, I greatly appreciate your help. But I am still a bit confused. To set the attribute I need to have the alias for MPTT (or, actually any class that inherits MPTT mixin class) table. But I can not use aliased() neither inside the MPTT definition nor after it — in both cases I get

Re: [sqlalchemy] aliased in mixins

2012-07-31 Thread Michael Bayer
On Jul 31, 2012, at 11:42 AM, Sergey Kucheryavski wrote: > I would like to use Mixin to make a base class for MPTT trees, just as an > example > > class MPTT(object): > @declared_attr > def __tablename__(cls): > return cls.__name__.lower() > > id = db.Column(db.Integer, pri

[sqlalchemy] aliased in mixins

2012-07-31 Thread Sergey Kucheryavski
I would like to use Mixin to make a base class for MPTT trees, just as an example class MPTT(object): @declared_attr def __tablename__(cls): return cls.__name__.lower() id = db.Column(db.Integer, primary_key = True) level = db.Column(db.Integer, nullable = False) lft