从Plone中的BrowserViews返回HTTP错误代码

时间:2012-09-15 21:49:23

标签: plone

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,但结果是“我们很抱歉,似乎有...”页面上的用户。我只想将纯文本信息缩短到浏览器。

1 个答案:

答案 0 :(得分:2)

不,除了提出zException内置异常并调用self.request.response.setStatus()之外,没有其他方法可以影响状态代码。