当前位置: 首页>>代码示例>>Python>>正文


Python Page.by_revision方法代码示例

本文整理汇总了Python中models.Page.by_revision方法的典型用法代码示例。如果您正苦于以下问题:Python Page.by_revision方法的具体用法?Python Page.by_revision怎么用?Python Page.by_revision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Page的用法示例。


在下文中一共展示了Page.by_revision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import by_revision [as 别名]
def show(name):
    revision = request.args.get('rev')
    if revision:
        revision = Page.by_revision(revision)
        revision_requested = True
    else:
        revision = Page.by_name(name)
        revision_requested = False
    if revision is None:
        return (web.render_template('missing.html',
                revision_requested=revision_requested,
                page_name=name,
                protected=False), 404)
    return web.render_template('show.html', revision=revision)
开发者ID:cloudappsetup,项目名称:kalapy,代码行数:16,代码来源:views.py

示例2: revert

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import by_revision [as 别名]
def revert(name):
    """Revert an old revision."""
    rev_id = request.args.get('rev')
    try:
        rev_id = int(rev_id)
    except:
        pass

    old_revision = page = None
    error = _('No such revision')

    if request.method == 'POST' and request.form.get('cancel'):
        return web.redirect(web.url_for('show', name=page_name))

    if rev_id:
        old_revision = Page.by_revision(rev_id)
        if old_revision:
            new_revision = Page.by_name(name)
            if old_revision == new_revision:
                error = _('You tried to revert the current active ' \
                          'revision.')
            elif old_revision.text == new_revision.text:
                error = _('There are no changes between the current ' \
                          'revision and the revision you want to ' \
                          'restore.')
            else:
                error = ''
                page = old_revision.page
                if request.method == 'POST':
                    note = request.form.get('note', '')
                    note = 'revert' + (note and ': ' + note or '')
                    revision = Revision(page=page, text=old_revision.text,
                                         note=note)
                    revision.save()
                    db.commit()
                    return web.redirect(web.url_for('show', name=name))

    return web.render_template('revert.html',
        error=error,
        old_revision=old_revision,
        revision=page
    )
开发者ID:cloudappsetup,项目名称:kalapy,代码行数:44,代码来源:views.py


注:本文中的models.Page.by_revision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。