These are the predicate checkers that are included with repoze.what:
Predicate is the parent class of every predicate checker and its API is described below:
Negate the specified predicate.
|Parameters:||predicate – The predicate to be negated.|
# The user *must* be anonymous: p = Not(NotAnonymous())
You may create a compound predicate by aggregating single (or even compound) predicate checkers with the functions below:
Check that all of the specified predicates are met.
|Parameters:||predicates – All of the predicates that must be met.|
# Grant access if the current month is July and the user belongs to # the human resources group. p = All(IsMonth(7), InGroup('hr'))
This predicate is met when all the inner predicates are met, unmet when at least one of them is unmet and indeterminate for the rest of the situation.
Check that at least one of the specified predicates is met.
|Parameters:||predicates – Any of the predicates that must be met.|
# Grant access if the currest user is Richard Stallman or Linus # Torvalds. p = Any(IsUser("rms"), IsUser("linus"))
This predicate is met when at least one of the inner predicates is met and unmet when all of the inner predicates are unmet. If none of the predicates are met and also there’s at least one indeterminate predicate, this predicate is indeterminate.
But you can also nest compound predicates:
p = All(Any(is_month(4), is_month(10)), has_permission('release'))
Which may be translated as “Anyone granted the ‘release’ permission may release a version of Ubuntu, if and only if it’s April or October”.