电子邮件主题的多个过滤器查询的错误架构验证(由于 "The maximum read depth (32) has been exceeded")
ErrorSchemaValidation upon multiple filter queries on email subject (due to "The maximum read depth (32) has been exceeded")
我需要过滤掉主题包含我配置的列表中的任何字符串的电子邮件。我尝试使用几个 Q 表达式按如下方式构建查询,因为目前(我最后检查过)不支持查询 subject__in=["somestring1", "somestring2", ... "somestring25"].
list_of_subject_filter_string_patterns = ["somestring1", "somestring2", ... "somestring25"]
filtered_items = my_exchange_account.inbox.filter(**kwargs)
query_sections = (Q(subject__icontains=pattern) for pattern in list_of_subject_filter_string_patterns)
query = reduce(operator.or_, query_sections)
filtered_items = filtered_items.filter(~query)
if filtered_items.exists():
# do something
....
然而,当我在该 Q 楼中传递更长一点的模式列表时,这会爆炸。
File "/usr/local/lib/python3.6/site-packages/exchangelib/services/common.py", line 329, in _raise_soap_errors
raise vars(errors)[code](msg)
ErrorSchemaValidation: The request failed schema validation. The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 499.
关于如何实现过滤掉多个主题模式的预期查询结果有什么想法吗?
我认为您的减少没有达到预期效果。 reduce()
可能会产生类似 (((("somestring1" OR "somestring2") OR "somestring3") OR "somestring4") OR "somestring5) ...
的内容,这对于 Exchange 服务器来说太多了。您可以启用 debug logging 来检查 XML.
的确切格式
如果您希望字符串完全匹配,exchangelib 支持 subject__in=[...]
。参见 https://ecederstrand.github.io/exchangelib/#searching
我需要过滤掉主题包含我配置的列表中的任何字符串的电子邮件。我尝试使用几个 Q 表达式按如下方式构建查询,因为目前(我最后检查过)不支持查询 subject__in=["somestring1", "somestring2", ... "somestring25"].
list_of_subject_filter_string_patterns = ["somestring1", "somestring2", ... "somestring25"]
filtered_items = my_exchange_account.inbox.filter(**kwargs)
query_sections = (Q(subject__icontains=pattern) for pattern in list_of_subject_filter_string_patterns)
query = reduce(operator.or_, query_sections)
filtered_items = filtered_items.filter(~query)
if filtered_items.exists():
# do something
....
然而,当我在该 Q 楼中传递更长一点的模式列表时,这会爆炸。
File "/usr/local/lib/python3.6/site-packages/exchangelib/services/common.py", line 329, in _raise_soap_errors
raise vars(errors)[code](msg)
ErrorSchemaValidation: The request failed schema validation. The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 499.
关于如何实现过滤掉多个主题模式的预期查询结果有什么想法吗?
我认为您的减少没有达到预期效果。 reduce()
可能会产生类似 (((("somestring1" OR "somestring2") OR "somestring3") OR "somestring4") OR "somestring5) ...
的内容,这对于 Exchange 服务器来说太多了。您可以启用 debug logging 来检查 XML.
如果您希望字符串完全匹配,exchangelib 支持 subject__in=[...]
。参见 https://ecederstrand.github.io/exchangelib/#searching