TurboGears / tgext.pluggable

Pluggable applications support for TurboGears2
11 stars 13 forks source link

many to many relation creattion failed #15

Open shaverlee opened 10 years ago

shaverlee commented 10 years ago

A typical many to many relation code like this (from Sqlalchemy's documents):

association_table = Table('association', Base.metadata, Column('left_id', Integer, ForeignKey('left.id')), Column('right_id', Integer, ForeignKey('right.id')) )

class Parent(Base): tablename = 'left' id = Column(Integer, primary_key=True) children = relationship("Child", secondary=association_table)

class Child(Base): tablename = 'right' id = Column(Integer, primary_key=True)

after run "gearbox setup-app", the association_table didn't create, and the same code in Application's models worked correctly. after I study the pluaggble's code, I found in sqla/models.py:

class SQLAModelsSupport(object): def is_model(self, model): return inspect.isclass(model) and hasattr(model, 'tablename')

so the subclass of Base has the attribute "tablename", but a instance of Table seems not.