本文整理汇总了Python中kuma.wiki.search.WikiDocumentType.should_update方法的典型用法代码示例。如果您正苦于以下问题:Python WikiDocumentType.should_update方法的具体用法?Python WikiDocumentType.should_update怎么用?Python WikiDocumentType.should_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kuma.wiki.search.WikiDocumentType
的用法示例。
在下文中一共展示了WikiDocumentType.should_update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_delete_handler
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def pre_delete_handler(instance, **kwargs):
if not settings.ES_LIVE_INDEX:
return
doc = instance
current_index = Index.objects.get_current()
if WikiDocumentType.should_update(doc):
unindex_documents.delay([doc.pk], current_index.pk)
else:
log.info('Ignoring wiki document %r while updating search index',
doc.pk, exc_info=True)
示例2: pre_delete_handler
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def pre_delete_handler(**kwargs):
if not settings.ES_LIVE_INDEX or 'instance' not in kwargs:
return
from kuma.wiki.tasks import unindex_documents
from .models import Index
doc = kwargs['instance']
current_index = Index.objects.get_current()
if WikiDocumentType.should_update(doc):
unindex_documents.delay([doc.pk], current_index.pk)
else:
log.info('Ignoring wiki document %r while updating search index',
doc.pk, exc_info=True)
示例3: render_done_handler
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def render_done_handler(instance, **kwargs):
if not settings.ES_LIVE_INDEX:
return
doc = instance
if WikiDocumentType.should_update(doc):
current_index = Index.objects.get_current()
outdated = current_index.record_outdated(doc)
if outdated:
log.info('Found a newer index and scheduled '
'indexing it after promotion.')
doc_pks = set([item.pk for item in doc.other_translations])
doc_pks.add(doc.id)
try:
index_documents.delay(list(doc_pks), current_index.pk)
except Exception:
log.error('Search indexing task failed', exc_info=True)
else:
log.info('Ignoring wiki document %r while updating search index',
doc.id, exc_info=True)
示例4: render_done_handler
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def render_done_handler(**kwargs):
if not settings.ES_LIVE_INDEX or 'instance' not in kwargs:
return
from kuma.wiki.tasks import index_documents
from .models import Index
doc = kwargs['instance']
if WikiDocumentType.should_update(doc):
current_index = Index.objects.get_current()
outdated = current_index.record_outdated(doc)
if outdated:
log.info('Found a newer index and scheduled '
'indexing it after promotion.')
doc_pks = set(doc.other_translations.values_list('pk', flat=True))
doc_pks.add(doc.id)
try:
index_documents.delay(list(doc_pks), current_index.pk)
except:
log.error('Search indexing task failed', exc_info=True)
else:
log.info('Ignoring wiki document %r while updating search index',
doc.id, exc_info=True)
示例5: test_should_not_update_excluded_flags
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def test_should_not_update_excluded_flags(mock_doc, flag):
"""Do not update the search index if some flags are set."""
setattr(mock_doc, flag, True)
assert not WikiDocumentType.should_update(mock_doc)
示例6: test_should_not_update_excluded_slug
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def test_should_not_update_excluded_slug(mock_doc, slug):
"""Excluded slugs should not update the search index."""
mock_doc.slug = slug
assert not WikiDocumentType.should_update(mock_doc)
示例7: test_should_update_standard_doc
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def test_should_update_standard_doc(mock_doc):
"""The mock_doc should update search index."""
assert WikiDocumentType.should_update(mock_doc)
示例8: test_hidden_slugs_should_update
# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import should_update [as 别名]
def test_hidden_slugs_should_update(self):
jezdez_doc = Document.objects.get(slug='User:jezdez')
eq_(WikiDocumentType.should_update(jezdez_doc), False)