我已经看过文档,但我无法使其正常工作。如果有人能更清楚地向我解释如何在金字塔中创建自定义403页面,那就太棒了
由于
答案 0 :(得分:1)
您可以向@forbidden_view_config()
装饰器添加渲染器:
@forbidden_view_config(renderer='myforbiddentemplate.mako')
或者,你也可以做一些自定义视图:
from pyramid.httpexceptions import (
HTTPFound,
HTTPNotFound,
HTTPForbidden,
HTTPBadRequest,
HTTPInternalServerError
)
@view_config(context=HTTPNotFound, renderer='HTTPNotFoundPage.mako')
def my_view(request):
答案 1 :(得分:0)
使用forbidden_view_config解析你的观点:
@view_config(route_name='login', renderer='login-page.mako')
@forbidden_view_config(renderer='login-page.mako')
def login_view(request):
return {}
答案 2 :(得分:0)
from pyramid.view import forbidden_view_config
@forbidden_view_config(renderer='your_template_name')
def forbidden_view(request):
request.response.status = 403
return {}