当前位置: 首页>>代码示例>>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;未经允许,请勿转载。