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))
How do I access weight column from Account objects
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---