I wonder would it be completely wrong to use an association object to
handle the relationship between contract, group, permission:
class GroupContractAssoc()
pass
group_contract_assoc_table = Table('group_contract_assoc', metadata,
Column('group_id', Integer, ForeignKey
('igroup.group_id'),primary_key=True),
Column('contract_id', Integer, ForeignKey
('contract.contract_id'),primary_key=True),
Column('permission_id',Integer, ForeignKey
('permission.permission_id'))
)
group.contracts would thus return a list with GroupContractAssoc
objects, each of which as a group_id, contract_id and permission_id
(would of course be better if the GroupContractAssoc object would
return group,contract and permission objects instead of just their
respective ids).
On 9 Apr., 08:24, Michael Brickenstein <[email protected]> wrote:
> I would maybe add a relation writeable_contracts to the group entity (-> join
> conditions in sqlalchemy).
>
> One you have that, you should be able to achieve a predicate, which
> you can register
>
> def group_can_write_contracts(policy, obj, action, attr, user):
> contract=obj
> for group in user.groups:
> if contract in group.writeable_contracts:
> return True
> return Denial("Only members of ... groups can write this
> contract")
> YourPolicy.register(group_can_write_contracts, obj=Contract,
> action=...,...)
>
> Michael
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---