interstitial.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:websauna 作者: websauna 项目源码 文件源码
def process_interstitial(request: Request, choices: t.List[Choice], *args, **kwargs):
    """Check if user pressed any of the buttons on form and the choice accordingly.

    For example use case see :py:class:`websauna.system.crud.views.Delete`.

    :param args: Passed to choice callback
    :param kwargs: Passed to choice callback
    :return: HTTP response given by a choice callback
    """
    assert request.method == "POST"

    # Force CSRF check always
    check_csrf_token(request)

    for c in choices:
        if c.id in request.POST:
            return c.callback(*args, **kwargs)

    raise HTTPBadRequest("Unknown choice made")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号