This matcher makes it possible to combine the results of several
matchers using logical operations. CombineMatcher uses
prefix-notation in its expressions and uses the following format:
the operand, a comma, first argument, a comma, second argument.
For example, an AND expression should be formatted the following
way: (Z_AND, matcher1, matcher2)
.
Expressions using more than one operands should be bracketed, e.g.,
(Z_OR (Z_AND, matcher1, matcher2), matcher3)
.
The following oprations are available:
Z_AND : Logical AND operation.
Z_OR : Logical OR operation.
Z_XOR : Logical XOR operation.
Z_NOT : Logical negation.
Z_EQ : Logical equation.
Example 5.21. Whitelisting e-mail recipients |
---|
A simple use for CombineMatcher is to filter the recipients of e-mail addresses using the following process:
Python: class SmtpRecipientMatcherProxy(SmtpProxy): recipient_matcher="SmtpCombineMatcher" def config(self): super(SmtpRecipientMatcherProxy, self).config() MatcherPolicy(name="SmtpCombineMatcher", matcher=CombineMatcher (expr=(Z_AND, "SmtpCheckrecipient", "SmtpWhitelist"))) MatcherPolicy(name="SmtpWhitelist", matcher=RegexpMatcher (match_list=("info@example.com",), ignore_list=None)) MatcherPolicy(name="SmtpCheckrecipient", matcher=SmtpInvalidRecipientMatcher (server_port=25, cache_timeout=60, attempt_delivery=FALSE, force_delivery_attempt=FALSE, server_name="recipientcheck.example.com")) |
Published on June 04, 2020
© 2007-2019 BalaSys
Send your comments to support@balasys.hu