Source

django-extauth / extauth / backend.py

Full commit
'''
Copyright 2009 H. Lee Moffitt Cancer Center and Research Institute, Inc. 
All rights reserved.

@author: Michael Hall <mhall119@gmail.com>
'''
from django.contrib.auth.backends import ModelBackend
from extauth import roles

class RoleBackend(ModelBackend):

    supports_object_permissions = True
    
    def has_perm(self, user_obj, perm, obj=None):
        if obj is None:
            return False
            
        obj_roles = roles.get_roles(obj, user_obj)
        return obj_roles.has_perm(perm)
        
    def get_group_permissions(self, user_obj, obj=None):
        return None
        
    def get_all_permissions(self, user_obj, obj=None):
        obj_roles = roles.get_roles(obj, user_obj)
        return obj_roles.getUserPerms()
        
    def has_module_perms(self, user_obj, app_label, obj=None):
        return False