I cant speak for the ActiveMapper style, however association objects
are supported by mappers in general, see the example "association
object" (http://www.sqlalchemy.org/docs/
datamapping.myt#datamapping_association ) as well as the example
TopicAssociation mapper in the Myghty ZBlog demo ( http://
www.myghty.org/trac/browser/myghty/trunk/examples/zblog/lib/zblog/
database/mappers.py ).
Im not sure how much people have worked with association objects as
of yet, there is a little extra work going on to make them happen, so
let me know of any issues you have.
On Mar 9, 2006, at 6:48 AM, Qvx 3000 wrote:
I have two tables (Account & Phonebook) with Many-to-Many relationship
implemented using association table (cc_account_phonebook). This
association table has additional columns besides ID columns (weigh). I
would like to have access to those extra columns while accessing list
of related objects.
Here is my simplified model (using ActiveMapper syntax):
account_phonebook_table = Table( "cc_account_phonebook", __engine__,
Column("account_id", Integer, ForeignKey("cc_account.id"),
primary_key=True),
Column("phonebook_id", Integer, ForeignKey("cc_phonebook.id"),
primary_key=True),
Column("weight", Integer))
class AccountPhonebook(object):
pass
AccountPhonebook.mapper = mapper(AccountPhonebook,
account_phonebook_table)
class Account(ActiveMapper):
class mapping:
__table__ = 'cc_account'
id = column(Integer, primary_key=True)
name = column(Unicode(50))
telefon = column(Unicode(40))
from_phonebook = many_to_many("Phonebook",
account_phonebook_table)
# I would like to have access to weight as well
class Phonebook(ActiveMapper):
class mapping:
__table__ = 'cc_phonebook'
id = column(Integer, primary_key=True)
name = column(Unicode(100))
telefon = column(Unicode(20))
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the
live webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users