librelist archives

« back to archive

How should I register error handlers without decorators?

How should I register error handlers without decorators?

From:
Italo Maia
Date:
2011-09-27 @ 16:35
Like this:

app.error_handler_spec[None][404] = page_not_found

or like this:

app.error_handlers[404] = page_not_found  # like in flask source
scripts/testproj

-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Bacharel em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
Turtle Linux  9.10 - http://tiny.cc/blogturtle910
Turtle Linux 10.10 - http://bit.ly/cEw4ET
===========================

Re: [flask] How should I register error handlers without decorators?

From:
Simon Sapin
Date:
2011-09-28 @ 07:20
Le 27/09/2011 18:35, Italo Maia a écrit :
> Like this:
>
> app.error_handler_spec[None][404] = page_not_found
>
> or like this:
>
> app.error_handlers[404] = page_not_found  # like in flask source
> scripts/testproj

Hi,

Decorators are just functions. You can call them directly:

     app.error_handler(404)(page_not_found)

Regards,
-- 
Simon Sapin