#NEWLINE# def check_permission( self , action , username , resource , perm ) : #NEWLINE# #INDENT# realm = ( resource . realm if resource else None ) #NEWLINE# if ( ( realm , action ) in self . _handled_perms ) : #NEWLINE# #INDENT# ( authz , users ) = self . _get_authz_info ( ) #NEWLINE# if ( authz is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( username == 'anonymous' ) : #NEWLINE# #INDENT# usernames = ( '$anonymous' , '*' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# usernames = ( username , '$authenticated' , '*' ) #NEWLINE# #UNINDENT# if ( resource is None ) : #NEWLINE# #INDENT# return ( True if ( users & set ( usernames ) ) else None ) #NEWLINE# #UNINDENT# rm = RepositoryManager ( self . env ) #NEWLINE# try : #NEWLINE# #INDENT# repos = rm . get_repository ( resource . parent . id ) #NEWLINE# #UNINDENT# except TracError : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( repos is None ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# modules = [ ( resource . parent . id or self . authz_module_name ) ] #NEWLINE# if modules [ 0 ] : #NEWLINE# #INDENT# modules . append ( '' ) #NEWLINE# #UNINDENT# def check_path( path ) : #NEWLINE# #INDENT# path = ( '/' + join ( repos . scope , path ) ) #NEWLINE# if ( path != '/' ) : #NEWLINE# #INDENT# path += '/' #NEWLINE# #UNINDENT# if any ( ( ( section . get ( user ) is True ) for module in modules for ( spath , section ) in authz . get ( module , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . iteritems ( ) if spath . startswith ( path ) for user in usernames ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# for spath in parent_iter ( path ) : #NEWLINE# #INDENT# for module in modules : #NEWLINE# #INDENT# section = authz . get ( module , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( spath ) #NEWLINE# if section : #NEWLINE# #INDENT# for user in usernames : #NEWLINE# #INDENT# result = section . get ( user ) #NEWLINE# if ( result is not None ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( realm == 'source' ) : #NEWLINE# #INDENT# return check_path ( resource . id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( realm == 'changeset' ) : #NEWLINE# #INDENT# changes = list ( repos . get_changeset ( resource . id ) . get_changes ( ) ) #NEWLINE# if ( ( not changes ) or any ( ( check_path ( changes [ 0 ] ) for change in changes ) ) ) : #NEWLINE# #INDENT# return True