routes.py 文件源码

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

项目:pillar 作者: armadillica 项目源码 文件源码
def redirect_to_context(node_id):
    """Redirects to the context URL of the node.

    Comment: redirects to whatever the comment is attached to + #node_id
        (unless 'whatever the comment is attached to' already contains '#', then
         '#node_id' isn't appended)
    Post: redirects to main or project-specific blog post
    Other: redirects to project.url + #node_id
    """

    if node_id.lower() == '{{objectid}}':
        log.warning("JavaScript should have filled in the ObjectID placeholder, but didn't. "
                    "URL=%s and referrer=%s",
                    request.url, request.referrer)
        raise wz_exceptions.NotFound('Invalid ObjectID')

    try:
        url = url_for_node(node_id)
    except ValueError as ex:
        log.warning("%s: URL=%s and referrer=%s",
                    str(ex), request.url, request.referrer)
        raise wz_exceptions.NotFound('Invalid ObjectID')

    return redirect(url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号