Last active
August 29, 2015 14:16
-
-
Save silenius/18190ef4912667e49b1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### | |
# ACCOUNT # | |
########### | |
orm.mapper(Account, table['account']) | |
######## | |
# POOL # | |
######## | |
orm.mapper(Pool, table['pool'], properties = { | |
'owner' : orm.relationship( | |
Account, | |
innerjoin = True, | |
backref = 'pools' | |
), | |
'facilitators' : orm.relationship( | |
Account, | |
secondary = table['account_role'], | |
secondaryjoin = lambda : sql.and_( | |
Account.id == AccountRole.account_id, | |
AccountRole.role_id == Role.id, | |
Role.name == 'facilitator' | |
), | |
backref = 'facilitated_pools' | |
) | |
}) | |
######## | |
# ROLE # | |
######## | |
orm.mapper(Role, table['role']) | |
################ | |
# ACCOUNT ROLE # | |
################ | |
orm.mapper(AccountRole, table['account_role'], properties = { | |
'human' : orm.relationship( | |
Account, | |
lazy = 'joined', | |
innerjoin = True, | |
backref = 'assigned' | |
), | |
'role' : orm.relationship( | |
Role, | |
lazy = 'joined', | |
innerjoin = True, | |
backref = 'assigned' | |
), | |
'pool' : orm.relationship( | |
Pool, | |
backref = 'assigned' | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment