开发者

Pylons middleware 404

开发者 https://www.devze.com 2023-02-18 22:28 出处:网络
i\'m new to Python and Pylons and want to know how it is possible to cancle the start routin of the pylons app.

i'm new to Python and Pylons and want to know how it is possible to cancle the start routin of the pylons app.

I found the middleware and want to do something like this:

    if error:
        abort(404)

But this brings me a 500 internal Server Er开发者_开发问答ror Message if error is true instead of a 404 Not Found Message.

Could anyone tell me how i can interupt start routin of pylons?


Try adding a message in the call:

abort(404,"404 Not Found");

As well, you can customize the error documents. See: http://wiki.pylonshq.com/display/pylonsdocs/Error+Documents#changing-the-template


The problem is with the condition not abort.

Try this way:

def test(self):
  username = ''
  if not username:
    abort(404)
0

精彩评论

暂无评论...
验证码 换一张
取 消