本文整理匯總了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)