All pastes #416017 Raw Edit

Untitled

public text v1 · immutable
#416017 ·published 2007-03-30 00:33 UTC
rendered paste body
class Not(CompoundPredicate):
    '''
    A compound predicate that evaluates to false
    if its sub-predicate evaluates to true.
    '''
    error_message= "No predicates were able to grant access"

    def eval_with_object(self, obj, errors=None):
        '''
        Return false if any sub-predicate evaluates to true.
        '''
        for p in self.predicates:
            if p.eval_with_object( obj, None ):
                self.append_error_message( errors )
                return False
        return True


@identity.require(Not(identity.in_any_group("admin", "special")))