> If the assumptions made in the TurboGears identity provider code were
> accurate, class_mapper(Foo).props would contain an element associated
> with 'bars'; in practice, it does not.
>
> Is this an issue with ActiveMapper, or with the assumptions made by
> the
> TurboGears identity provider? I'm working with TurboGears trunk r1557
> and SQLAlchemy trunk r1622.
The issue is neither of these things. Its the fact that you aren't
defining the metadata for the mapping table properly. Also, you are
adding backrefs to things that already exist. Here is some code that
should work:
import sqlalchemy.mods.threadlocal
from sqlalchemy import *
from sqlalchemy.ext.activemapper import *
import sqlalchemy.ext.activemapper as activemapper
activemapper.metadata.connect('sqlite:///:memory:')
foo_bar_map_table = Table('foo_bar_map',
activemapper.metadata,
Column('foo_id', Integer,
ForeignKey('foo_tbl.foo_id'),
primary_key=True
),
Column('bar_id', Integer,
ForeignKey('bar_tbl.bar_id'),
primary_key=True
)
)
class Foo(ActiveMapper):
class mapping:
__table__ = 'foo_tbl'
foo_id = column(Integer, primary_key=True)
foo_text = column(String(30))
bars = many_to_many('Bar', foo_bar_map_table,
backref='foos')
class Bar(ActiveMapper):
class mapping:
__table__ = 'bar_tbl'
bar_id = column(Integer, primary_key=True)
bar_text = column(String(30))
from pprint import pprint
pprint(class_mapper(Foo).props)
pprint(class_mapper(Bar).props)
Let me know if this helps you out.
--
Jonathan LaCour
http://cleverdevil.org
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users