Re: [flask] bottle's Response exception
- From:
- Armin Ronacher
- Date:
- 2011-04-14 @ 23:25
Hi,
On 2011-04-14 11:50 PM, Rob Mela wrote:
> One of the things I thought was interesting was that at any
> point in your code you can "raise" a response.
You can do the same in Flask if you really want to:
@app.route('/')
def foo():
abort(Respone("Hello World!"))
Regards,
Armin
Re: [flask] bottle's Response exception
- From:
- dag.odenhall@gmail.com
- Date:
- 2011-04-16 @ 19:05
On 15 April 2011 01:25, Armin Ronacher <armin.ronacher@active-4.com> wrote:
> Hi,
>
> On 2011-04-14 11:50 PM, Rob Mela wrote:
>> One of the things I thought was interesting was that at any
> > point in your code you can "raise" a response.
> You can do the same in Flask if you really want to:
>
> @app.route('/')
> def foo():
> abort(Respone("Hello World!"))
>
>
> Regards,
> Armin
>
Is that not special-cased and triggering errorhandlers for example?
Re: [flask] bottle's Response exception
- From:
- Simon Sapin
- Date:
- 2011-04-16 @ 19:49
Le 16/04/2011 21:05, dag.odenhall@gmail.com a écrit :
> Is that not special-cased and triggering errorhandlers for example?
Hi,
Error handlers are used if you pass a status code, eg ``abort(404)``,
not if you pass a Response object.
Regards,
--
Simon Sapin
Re: [flask] bottle's Response exception
- From:
- Joe Esposito
- Date:
- 2011-04-14 @ 22:03
Wow, interesting.
If used generally it would certainly go against "exceptions should only be
used in truly exceptional cases."
It'd be nice for quick hacks and displaying errors quickly, but I think in
most cases it'd be unintuitive or unexpected if someone else's code did it
to you.
On Thu, Apr 14, 2011 at 5:50 PM, Rob Mela <rob@thinkingscreen.com> wrote:
> I took a quick look at Bottle after seeing the web frameworks shootout.
>
> One of the things I thought was interesting was that at any point in your
> code you can "raise" a response.
>
> This means that you can be several levels deep into a call stack and
> "throw" a response, without having to return it all the way down the call
> chain. This is really convenient if you have a call chain that includes
> functions that normally return something other than a response.
>
> Any thoughts?
>