this is the association object pattern, as described at:  
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_patterns_association

with that pattern, you should specifically *not* use the "secondary"  
argument on your mapper as the group_user_tbl will be explicitly mapped.

After setting that up you may want to look at the association proxy  
which can smooth some of the clumsiness of dealing with an association  
object: http://www.sqlalchemy.org/docs/04/plugins.html#plugins_associationproxy

On Feb 13, 2008, at 9:38 AM, g wrote:

>
> Say we have a many-to-many relation:
>
> mapper(Group, group_tbl,
>  properties={'users' : relation(User, secondary=group_user_tbl) }
> )
>
> group_user_tbl = Table('group_user', metadata,
>     Column('group_id', Integer, ForeignKey('group.group_id')),
>     Column('user_id', Integer, ForeignKey('user.user_id')),
>     Column('expiry', DateTime)
> )
>
> Is there any way to make the 'expiry' an attribute to the User of a
> particular Group?
> eg.
> my_group = session.query(Group).get(30)
> u = my_group.users[0]
> exp = u.expiry
> exp = datetime.datetime.now()
> session.flush()
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to