librelist archives

« back to archive

Flask & JSONP

Flask & JSONP

From:
Ron DuPlain
Date:
2012-05-08 @ 20:00
All:

JSONP will not be supported in the Flask core; this would be best
supported by an extension.

We've had requests for JSONP support in Flask for some time. A pull
request made it into the master branch of Flask's repository which
added a padded keyword to flask.jsonify, and has been accessible in
the unreleased 0.9 version of Flask. It will now be removed -- note
this if you are using the unreleased 0.9-dev version.

JSONP is no longer something that is absolutely necessary (see: CORS)
and it's simple enough to implement yourself if you need it. We made a
few passes toward a good API for JSONP with flask.jsonify, but decided
it's best left to custom implementation or a community extension.

JSONP would benefit from CSRF protection, which could use the
Flask-SeaSurf extension. At least one developer, jfinkels, has
expressed interest in developing a Flask-JSONP extension:

https://github.com/mitsuhiko/flask/pull/502

Sorry for any inconvenience. We were sure to resolve this before it
went into a Flask release.

-Ron

Re: [flask] Flask & JSONP

From:
Todd Kennedy
Date:
2012-05-08 @ 20:14
CORS support is broken in IE until at least IE 10.  (It's working in the 
latest beta, but who knows what happens when they release it).

You can't make an HTTPS request to an alternate domain from IE until IE 10
at all.  The only way to retrieve data from the non-originating URL over 
an HTTPS connection is do it via JSONP.

For HTTP requests you have to use the XDomainRequest object which 
disallows the setting of any headers (including content-type) and 
generally makes life extremely difficult (jQuery doesn't do a very good 
job of abstracting this away).

It would be VERY nice to have JSONP supported in the Flask core.  Sadly IE
9 is on the upswing, so there are many, many valid use-cases of this.

Thanks


On May 8, 2012, at 4:00 PM, Ron DuPlain wrote:

> All:
> 
> JSONP will not be supported in the Flask core; this would be best
> supported by an extension.
> 
> We've had requests for JSONP support in Flask for some time. A pull
> request made it into the master branch of Flask's repository which
> added a padded keyword to flask.jsonify, and has been accessible in
> the unreleased 0.9 version of Flask. It will now be removed -- note
> this if you are using the unreleased 0.9-dev version.
> 
> JSONP is no longer something that is absolutely necessary (see: CORS)
> and it's simple enough to implement yourself if you need it. We made a
> few passes toward a good API for JSONP with flask.jsonify, but decided
> it's best left to custom implementation or a community extension.
> 
> JSONP would benefit from CSRF protection, which could use the
> Flask-SeaSurf extension. At least one developer, jfinkels, has
> expressed interest in developing a Flask-JSONP extension:
> 
> https://github.com/mitsuhiko/flask/pull/502
> 
> Sorry for any inconvenience. We were sure to resolve this before it
> went into a Flask release.
> 
> -Ron

Re: [flask] Flask & JSONP

From:
Ron DuPlain
Date:
2012-05-08 @ 20:19
On Tue, May 8, 2012 at 4:14 PM, Todd Kennedy wrote:
> It would be VERY nice to have JSONP supported in the Flask core.
> Sadly IE 9 is on the upswing, so there are many, many valid
> use-cases of this.

How many Flask extensions do you typically have installed for your
projects? Even on my smallest Flask projects, I have one or two
extensions installed. A Flask-JSONP extension would just be one more.

-Ron

Re: [flask] Flask & JSONP

From:
Todd Kennedy
Date:
2012-05-08 @ 21:09
That's true, there are several.

I just figure that if JSON is supported, then adding JSONP might be worth-while.

But then again, I'd really rather Flask not become another Firefox or Django...


On May 8, 2012, at 4:19 PM, Ron DuPlain wrote:

> On Tue, May 8, 2012 at 4:14 PM, Todd Kennedy wrote:
>> It would be VERY nice to have JSONP supported in the Flask core.
>> Sadly IE 9 is on the upswing, so there are many, many valid
>> use-cases of this.
> 
> How many Flask extensions do you typically have installed for your
> projects? Even on my smallest Flask projects, I have one or two
> extensions installed. A Flask-JSONP extension would just be one more.
> 
> -Ron

Re: [flask] Flask & JSONP

From:
Zach Williams
Date:
2012-05-08 @ 21:45
Here's a gist I use for JSONP support: https://gist.github.com/1377985

Zach

On Tue, May 8, 2012 at 2:09 PM, Todd Kennedy <todd.kennedy@gmail.com> wrote:

> That's true, there are several.
>
> I just figure that if JSON is supported, then adding JSONP might be
> worth-while.
>
> But then again, I'd really rather Flask not become another Firefox or
> Django...
>
>
> On May 8, 2012, at 4:19 PM, Ron DuPlain wrote:
>
> > On Tue, May 8, 2012 at 4:14 PM, Todd Kennedy wrote:
> >> It would be VERY nice to have JSONP supported in the Flask core.
> >> Sadly IE 9 is on the upswing, so there are many, many valid
> >> use-cases of this.
> >
> > How many Flask extensions do you typically have installed for your
> > projects? Even on my smallest Flask projects, I have one or two
> > extensions installed. A Flask-JSONP extension would just be one more.
> >
> > -Ron
>
>

Re: [flask] Flask & JSONP

From:
Todd Kennedy
Date:
2012-05-08 @ 21:49
jesus that's awesomely small.

thanks man!

On May 8, 2012, at 5:45 PM, Zach Williams wrote:

> Here's a gist I use for JSONP support: https://gist.github.com/1377985
> 
> Zach
> 
> On Tue, May 8, 2012 at 2:09 PM, Todd Kennedy <todd.kennedy@gmail.com> wrote:
> That's true, there are several.
> 
> I just figure that if JSON is supported, then adding JSONP might be worth-while.
> 
> But then again, I'd really rather Flask not become another Firefox or Django...
> 
> 
> On May 8, 2012, at 4:19 PM, Ron DuPlain wrote:
> 
> > On Tue, May 8, 2012 at 4:14 PM, Todd Kennedy wrote:
> >> It would be VERY nice to have JSONP supported in the Flask core.
> >> Sadly IE 9 is on the upswing, so there are many, many valid
> >> use-cases of this.
> >
> > How many Flask extensions do you typically have installed for your
> > projects? Even on my smallest Flask projects, I have one or two
> > extensions installed. A Flask-JSONP extension would just be one more.
> >
> > -Ron
> 
> 

Re: [flask] Flask & JSONP

From:
Werner
Date:
2012-05-09 @ 09:23
Hi,

Maybe you should throw some sort of DeprecatedError instead. This is going
to be confusing for people who don't read the ml every day.

Regards 


On Tuesday 8 May 2012 at 23:45, Zach Williams wrote:

> Here's a gist I use for JSONP support: https://gist.github.com/1377985
> 
> Zach
> 
> On Tue, May 8, 2012 at 2:09 PM, Todd Kennedy <todd.kennedy@gmail.com 
(mailto:todd.kennedy@gmail.com)> wrote:
> > That's true, there are several.
> > 
> > I just figure that if JSON is supported, then adding JSONP might be 
worth-while.
> > 
> > But then again, I'd really rather Flask not become another Firefox or 
Django...
> > 
> > 
> > On May 8, 2012, at 4:19 PM, Ron DuPlain wrote:
> > 
> > > On Tue, May 8, 2012 at 4:14 PM, Todd Kennedy wrote:
> > >> It would be VERY nice to have JSONP supported in the Flask core.
> > >> Sadly IE 9 is on the upswing, so there are many, many valid
> > >> use-cases of this.
> > >
> > > How many Flask extensions do you typically have installed for your
> > > projects? Even on my smallest Flask projects, I have one or two
> > > extensions installed. A Flask-JSONP extension would just be one more.
> > >
> > > -Ron
> > 
> 

Re: [flask] Flask & JSONP

From:
Simon Sapin
Date:
2012-05-09 @ 09:28
Le 09/05/2012 11:23, Werner a écrit :
> Maybe you should throw some sort of DeprecatedError instead. This is
> going to be confusing for people who don't read the ml every day.

It was only in the git version, never in a release.

Regards,
-- 
Simon Sapin

Re: [flask] Flask & JSONP

From:
Werner
Date:
2012-05-09 @ 21:04
I read in the doc that it was a new in version 0.9[1], but that hasn't 
been released.

http://flask.pocoo.org/docs/api/#returning-json  


On Wednesday 9 May 2012 at 11:28, Simon Sapin wrote:

> Le 09/05/2012 11:23, Werner a écrit :
> > Maybe you should throw some sort of DeprecatedError instead. This is
> > going to be confusing for people who don't read the ml every day.
> >  
>  
>  
> It was only in the git version, never in a release.
>  
> Regards,
> --  
> Simon Sapin
>  
>