#NEWLINE# def is_allowed( self , role , operation , resource , check_allowed = True , **assertion_kwargs ) : #NEWLINE# #INDENT# 'Check the permission.\n\n        If the access is denied, this method will return False; if the access\n        is allowed, this method will return True; if there is not any rule\n        for the access, this method will return None.\n        ' #NEWLINE# assert ( ( not role ) or ( role in self . _roles ) ) #NEWLINE# assert ( ( not resource ) or ( resource in self . _resources ) ) #NEWLINE# roles = set ( get_family ( self . _roles , role ) ) #NEWLINE# operations = { None , operation } #NEWLINE# resources = set ( get_family ( self . _resources , resource ) ) #NEWLINE# is_allowed = None #NEWLINE# default_assertion = ( lambda * args , **kwargs : True ) #NEWLINE# for permission in itertools . product ( roles , operations , resources ) : #NEWLINE# #INDENT# if ( permission in self . _denied ) : #NEWLINE# #INDENT# assertion = ( assertion_kwargs . _denied [ permission ] or default_assertion ) #NEWLINE# if assertion ( self , role , operation , resource , ** assertion_kwargs ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( check_allowed and ( permission in self . _allowed ) ) : #NEWLINE# #INDENT# assertion = ( self . _allowed [ permission ] or default_assertion ) #NEWLINE# if assertion ( self , role , operation , resource , ** assertion_kwargs ) : #NEWLINE# #INDENT# is_allowed = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return is_allowed