示例#1
0
def queue_index_actions(blog, include_manual=False):
    '''
    Pushes to the publishing queue all the index pages for a given blog
    that are marked for Immediate publishing.

    :param blog:
        The blog object whose index templates will be pushed to the queue.
    :param include_manual:
        If set to True, all templates, including those set to the Manual publishing mode,
        will be pushed to the queue. Default is False, since those templates are not
        pushed in most publishing actions.
    '''

    templates = blog.index_templates.select().where(
        Template.publishing_mode != publishing_mode.do_not_publish)

    if include_manual is False:
        templates = templates.select().where(
            Template.publishing_mode == publishing_mode.immediate)

    if templates.count() == 0:
        raise Template.DoesNotExist(
            "No valid index templates exist for blog {}.".format(blog.for_log))

    mappings = TemplateMapping.select().where(
        TemplateMapping.template << templates)

    fileinfos = FileInfo.select().where(FileInfo.template_mapping << mappings)

    for f in fileinfos:
        Queue.push(job_type=job_type.index,
                   priority=1,
                   blog=blog,
                   site=blog.site,
                   data_integer=f.id)
示例#2
0
def queue_index_actions(blog):
    '''
    Pushes to the publishing queue all the index pages for a given blog
    that are marked for Immediate publishing.
    '''

    try:
        templates = Template.select().where(
            Template.blog == blog,
            Template.template_type == template_type.index,
            Template.publishing_mode == publishing_mode.immediate)

        if templates.count() == 0:
            raise Template.DoesNotExist

    except Template.DoesNotExist:
        raise Template.DoesNotExist(
            "No index templates exist for blog {}.".format(blog.for_log))

    else:

        mappings = TemplateMapping.select().where(
            TemplateMapping.template << templates)

        fileinfos = FileInfo.select().where(
            FileInfo.template_mapping << mappings)

        for f in fileinfos:

            push_to_queue(job_type=job_type.index,
                          priority=1,
                          blog=blog,
                          site=blog.site,
                          data_integer=f.id)