Object level cascading permission in Django

Projects such as Django-guardian and django-permissions enables you to have object level permissions. However, if two objects are related to each other by a parent-child relationship, is there any way for the child object to inherit permission from the parent object unless otherwise specified? For instance, a subfolder should inherit permission from parent folder unless a user explicitly assigns a different permission for the subfolder.

What's the best way to accomplish this using Django, in particular, the Django-guardian module?


When you check if a user has permissions on an object, and doesn't, then you can check if it has permission on its parent.

You might even want to make your own function, for example:

def your_has_perm(user, perm, obj):
    has = user.has_perm(perm, obj)

    if not has and hasattr(obj, 'parent'):
        return your_has_perm(user, perm, obj.parent)

    return has

This should traverse parents until it finds a permission for a parent or return False.

Need Your Help

Upload in Dailymotion using Google Drive or via email

google-drive-api dailymotion-api

I have some video in google drive. Can I upload them directly from Google Drive to dailymotion ? or can I upload file via email as attachment ?

Best way to save data for later use?

android xml data-storage

What is the best way to save multiple (about 80) fields as a single entity? My app creates a "program" object which itself contains about 75 Strings in an array, about 4 other random Strings, and a