Plone视图支持通过变异设置HTTP响应的返回码
http://collective-docs.readthedocs.org/en/latest/serving/http_request_and_response.html#return-code
...但是有没有任何金字塔/ Django样式可以从浏览器视图返回人类可读的HTTP错误代码。沿袭:
class View(BrowserView):
def __call__(self):
# Any nice classes to return here?
return Forbidden("Sauna area is forbidden due to on-going repairement work")
另外我知道你可以抛出zException,但结果是“我们很抱歉,似乎有...”页面上的用户。我只想将纯文本信息缩短到浏览器。
答案 0 :(得分:2)
不,除了提出zException内置异常并调用self.request.response.setStatus()
之外,没有其他方法可以影响状态代码。