當前位置: 首頁>>代碼示例>>Python>>正文


Python WikiDocumentType.should_update方法代碼示例

本文整理匯總了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)
開發者ID:Elchi3,項目名稱:kuma,代碼行數:14,代碼來源:signal_handlers.py

示例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)
開發者ID:caktus,項目名稱:kuma,代碼行數:17,代碼來源:signals.py

示例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)
開發者ID:Elchi3,項目名稱:kuma,代碼行數:22,代碼來源:signal_handlers.py

示例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)
開發者ID:iakshay,項目名稱:kuma,代碼行數:25,代碼來源:signals.py

示例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)
開發者ID:Elchi3,項目名稱:kuma,代碼行數:6,代碼來源:test_search.py

示例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)
開發者ID:Elchi3,項目名稱:kuma,代碼行數:6,代碼來源:test_search.py

示例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)
開發者ID:Elchi3,項目名稱:kuma,代碼行數:5,代碼來源:test_search.py

示例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)
開發者ID:15ramky,項目名稱:kuma,代碼行數:5,代碼來源:test_types.py


注:本文中的kuma.wiki.search.WikiDocumentType.should_update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。