Ticket #1343: none_predicate2.diff

File none_predicate2.diff, 0.8 kB (added by faide, 1 year ago)

same patch but with proper format

  • turbogears/identity/conditions.py

    old new  
    6464        self.append_error_message( errors ) 
    6565        return False 
    6666 
     67class NotAny(CompoundPredicate): 
     68    ''' 
     69    A compound predicate that evaluates to true only if no sub-predicates 
     70    evaluate to true for the given input. 
     71    ''' 
     72    error_message= "A predicate was able to grant access" 
     73  
     74    def eval_with_object( self, obj, errors=None ): 
     75        ''' 
     76        Return true if no sub-predicates evaluate to true. 
     77        ''' 
     78        for p in self.predicates: 
     79            if p.eval_with_object(obj, errors): 
     80                self.append_error_message(errors) 
     81                return False 
     82 
     83        return True 
    6784 
    6885class IdentityPredicateHelper(object): 
    6986    '''