How to make role inheritable?

18 views
Skip to first unread message

Alex Glaros

unread,
Jun 29, 2015, 3:56:20 PM6/29/15
to web...@googlegroups.com
Example: Role is "Citizen" (In db.auth_group)

Object (as in Subject/Predicate/Object) of role is "City of New Orleans" (Added extra field in db.auth_group "superObject" for this object role.)

In db.auth_membership, user_id is "Bob" with FK to db.auth_group.role. Result: "Bob is citizen of New Orleans."

So far so good, all New Orleans citizens are handled by being added to db.auth_membership

But Bob is also a citizen of Louisiana. And also a citizen of U.S.

How to have Louisiana and U.S. automatically inherit attributes so that system knows Bob is also citizen at state and federal level?

Goal is to have function in controller able to answer question "Is Bob a US citizen?" without having to redundantly place Bob in additional role groups (db.auth_group: state citizen role, db.auth_group: federal citizen role).

thanks,

Alex Glaros

Niphlod

unread,
Jun 29, 2015, 4:19:48 PM6/29/15
to web...@googlegroups.com
either you add redundantly groups or you have to resort to a recursive query each time you need to check for membership at higher levels than the first one... in either case I really don't see the issue: given that auth_membership is a one-to-many, web2py isn't getting in your way.

If you don't want to go for the multiple membership way, you can code easily a function that given the lowest membership checks recursively for higher levels in your own city-->state-->country-->world-->galaxy-->universe-->whatever map.

Alex Glaros

unread,
Jun 29, 2015, 8:02:11 PM6/29/15
to web...@googlegroups.com
exactly what I needed to know

thanks for the timely reply Niphlod

if future needs require, perhaps a graph DB would be effective for this type of query

Alex
Reply all
Reply to author
Forward
0 new messages