def set_perms(obj, fields, suffix, perms):
    old_perms = get_perms(obj, fields, suffix)
    for field in fields:
        for group in perms[field]:
            if group not in old_perms[field]:
                assign_perm(field + suffix, group, obj)
        for group in old_perms[field]:
            if group not in perms[field]:
                remove_perm(field + suffix, group, obj)
Set group perms on an object
dataset/ETHPy150Open Wtower/django-ninecms/ninecms/utils/perms.py/set_perms