core.utils.FetchingCriterion module¶
Module with the FetchingCriterion utility class.
- class core.utils.FetchingCriterion.FetchingCriterion(criterion, argument='')[source]¶
Bases:
objectClass encapsulating the fetching-criterion logic.
- Parameters:
criterion (EmailFetchingCriterionChoices)
argument (str)
- __init__(criterion, argument='')[source]¶
Constructor.
- Parameters:
criterion (
EmailFetchingCriterionChoices) – One of the class:core.constants.EmailFetchingCriterionChoices.argument (
str) – Argument for the criterion. Defaults to “”.
- Return type:
None
- __str__()[source]¶
The formatted criterion as a string.
- Return type:
- Returns:
The formatted string criterion.
- validate()[source]¶
Checks if this fetching criterion is valid.
Note
Things that are NOT validated here: - Availability of the criterion for the mailbox of fetcher. - Existence of the criterion in general (covered by checking the above)
- Raises:
ValueError – If this fetching criterion is invalid.
- Return type:
- as_imap_criterion()[source]¶
Returns the formatted criterion for the IMAP request, handles dates in particular.
Note
There’s no need to use timezone.now here as only the date part is used.
- Return type:
- Returns:
Formatted criterion to be used in IMAP request.
- as_jmap_filter()[source]¶
Returns the filter-condition for the JMAP Email/query request.
- Return type:
EmailQueryFilterCondition- Returns:
The filter-condition to be used in JMAP request.
- as_exchange_queryset(base_query)[source]¶
Returns the queryset for the Exchange request.
Note
Use no timezone here to use the mailserver time settings.
- Parameters:
base_query (
QuerySet) – The query to extend based on the criterion.- Return type:
QuerySet- Returns:
Augmented queryset to be used in Exchange request.