librelist archives

« back to archive

How can i use backbonejs and flask together in a efficient way? Can i?

How can i use backbonejs and flask together in a efficient way? Can i?

From:
lynadge
Date:
2012-09-10 @ 18:28
Hi!

Actually i use flask/django and want to structur my javascript with 
backbonejs.

Have anyone an good approach how i can do it?

I think backbonejs and flask have some similarities. When i use 
backbone, why i should use jinja?

As database i use MongoDB. Why i should use pymongo for flask?

Is there at all a way to combine Flask and BackboneJS?

If not, how do you structure your JS?

Regarts, L

Re: [flask] How can i use backbonejs and flask together in a efficient way? Can i?

From:
Anthony Nemitz
Date:
2012-09-10 @ 18:58
If you're thinking of a Flask/MongoDB/Backbone.js stack, I'd recommend 
taking a look at both Flask-MongoEngine 
(https://github.com/mongoengine/flask-mongoengine/) and Flask-MongoRest 
(https://github.com/elasticsales/flask-mongorest).

MongoEngine is a great ORM which will be very familiar to Django users and
MongoRest is a framework for generating restful api's on top of 
Flask/MongoEngine.

-A


On Sep 10, 2012, at 11:28 AM, lynadge <lynadge@barfooz.de> wrote:

> Hi!
> 
> Actually i use flask/django and want to structur my javascript with 
> backbonejs.
> 
> Have anyone an good approach how i can do it?
> 
> I think backbonejs and flask have some similarities. When i use 
> backbone, why i should use jinja?
> 
> As database i use MongoDB. Why i should use pymongo for flask?
> 
> Is there at all a way to combine Flask and BackboneJS?
> 
> If not, how do you structure your JS?
> 
> Regarts, L

Re: [flask] How can i use backbonejs and flask together in a efficient way? Can i?

From:
Todd Kennedy
Date:
2012-09-10 @ 19:07
I'm using Flask to generate a API as well, but I'm using SQLObject for my 
ORM and using Flask's MethodViews pattern.

I've written some code that translates SQLObject objects into standard 
Python dict and list objects so that they can be passed into json.dumps 
directly, it allows allows you to annotate the SQLObject definitions to 
define views of an object which restricts the fields returned as a JSON 
object (i.e. if you have an admin user and a normal user, certain fields 
will only be available to a person authorized as an admin).

All the "flask" owned URLs are under "/rest" so my server sends requests 
for /rest to the WSGI app; the other stuff comes directly from S3 for 
speed, but since it's all served under the same domain name, there's no 
CORS issues.

If I was starting from scratch though I'd definitely look into Mongo and 
use flask for a simple dummy in/out system.  Not that I don't like flask, 
but with the approach I'm taking I've got to maintain object definitions 
in both JavaScript and Python


On Sep 10, 2012, at 2:58 PM, Anthony Nemitz wrote:

> If you're thinking of a Flask/MongoDB/Backbone.js stack, I'd recommend 
taking a look at both Flask-MongoEngine 
(https://github.com/mongoengine/flask-mongoengine/) and Flask-MongoRest 
(https://github.com/elasticsales/flask-mongorest).
> 
> MongoEngine is a great ORM which will be very familiar to Django users 
and MongoRest is a framework for generating restful api's on top of 
Flask/MongoEngine.
> 
> -A
> 
> 
> On Sep 10, 2012, at 11:28 AM, lynadge <lynadge@barfooz.de> wrote:
> 
>> Hi!
>> 
>> Actually i use flask/django and want to structur my javascript with 
>> backbonejs.
>> 
>> Have anyone an good approach how i can do it?
>> 
>> I think backbonejs and flask have some similarities. When i use 
>> backbone, why i should use jinja?
>> 
>> As database i use MongoDB. Why i should use pymongo for flask?
>> 
>> Is there at all a way to combine Flask and BackboneJS?
>> 
>> If not, how do you structure your JS?
>> 
>> Regarts, L
> 

Re: [flask] How can i use backbonejs and flask together in a efficient way? Can i?

From:
Anderson Cardoso
Date:
2012-09-10 @ 19:08
Flask and backbone are in separate layers of your application. You can use
Backbone with any backend you wish, and you can use Flask with any
front-end framework you wish.
The fact you are using backbone does mean you have to drop jinja2. You can
use the best of both. In the backbone documentation he says the best
approach to reset a model is bootstraping on the page load, i.e., return
from Flask the page with your js files plus a json with your initial json
data.

I prefer use pymongo directly than using an ODM like mongoengine, because
Im using MongoDB for its schemaless nature, so for me adding a ODM which
forces a structure is undesired, but for doing this you must be very
disciplinate and code defensively (lot of tests and good classes that
abstracts the underlying db driver for you).

to communicate a flask view with backbone.sync you only have to expose a
rest-like api for your resources.

att

Anderson


2012/9/10 lynadge <lynadge@barfooz.de>

> Hi!
>
> Actually i use flask/django and want to structur my javascript with
> backbonejs.
>
> Have anyone an good approach how i can do it?
>
> I think backbonejs and flask have some similarities. When i use
> backbone, why i should use jinja?
>
> As database i use MongoDB. Why i should use pymongo for flask?
>
> Is there at all a way to combine Flask and BackboneJS?
>
> If not, how do you structure your JS?
>
> Regarts, L
>



-- 
Anderson Pierre Cardoso
Software Engineer - IT3S / University of Sao Paulo
*
http://www.apierrecardoso.com*
twitter: *@apierre_cardoso* <https://twitter.com/#%21/apierre_cardoso>

Re: [flask] How can i use backbonejs and flask together in a efficient way? Can i?

From:
Stefane Fermigier
Date:
2012-09-11 @ 06:56
You can have a look at:


http://thomassileo.com/blog/2012/09/10/build-a-backbone-slash-brunch-slash-chaplin-backend-with-python-flask-and-mongodb/

Cheers,

  S.

On Sep 10, 2012, at 8:28 PM, lynadge wrote:

> Hi!
> 
> Actually i use flask/django and want to structur my javascript with 
> backbonejs.
> 
> Have anyone an good approach how i can do it?
> 
> I think backbonejs and flask have some similarities. When i use 
> backbone, why i should use jinja?
> 
> As database i use MongoDB. Why i should use pymongo for flask?
> 
> Is there at all a way to combine Flask and BackboneJS?
> 
> If not, how do you structure your JS?
> 
> Regarts, L

-- 
Stefane Fermigier, tech entrepreneur
http://fermigier.com/ - http://twitter.com/sfermigier - 
http://www.linkedin.com/in/sfermigier
"Well done is better than well said." - Benjamin Franklin
"There's no such thing as can't. You always have a choice." - Ken Gor