Live data from Hacker News

Flask 0.7 Released (Python Web Framework)

flask.pocoo.org

71–80 of 80 posts

Re: Flask 0.7 Released (Python Web Framework)

#71

Flask is awesome and can be easily supercharged by pairing it with Paste Deploy: http://pythonpaste.org/deploy This way you get Flask simplicity and elegance, but also you get Rails-like separation of configuration test/development/production environments. Another misconception people seem to have is that Flask means Jinja2. Fortunately that's not the case, swapping Jinja with Mako is also extremely easy. Finally, Fl…

I notice that several projects (including Flask) do not build in support for DB schema management- e.g. migrations. For those of you who are writing apps in Flask, how do you guys manage changes in DB schema ?

I might be a little old school but I wouldn't seriously let a complicated system take care of schema migrations for me. Well, actually I do (in a system unrelated to Rails or Flask) and it's a mess.

For my current side-project, I'm actually building a thin ORM layer that basically handles migrations through hand-written SQL scripts.

Re: Flask 0.7 Released (Python Web Framework)

#72
post #39

Right now, I'm writing most of my projects in Tornado.. Not because I need the async, but because I wanted a simple web.py like format that was under active development. Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? I can understand the simplicity argument; I chose to avoid Django because it was t…

Flask is a simple web.py-like framework that is under active development, and I would argue it's one of the cleanest Python Web frameworks (if not the cleanest) out there.

My current project requires real-time stuff so I started to develop it using Tornado and then decided to switch to the Quora model -- use a traditional Web framework for most things, and connect back to Tornado for the real-time stuff.

Quora uses Pylons, but Pylons reached its end-of-life with 1.0, and it's now Pyramid, which is really repoze.bfd and shares no code with Pylons 1.0.

So I swapped out Pylons for Flask and use Sockeit.IO (http://socket.io/) to connect back to Torando for real-time connections.

In addition to just being really-well designed, Flask has an amazing debugger that makes me more productive, and it's easier to write unittests for Flask because you can write them in a traditional way and don't have to contend with Tornado's IOLoop.

When I switched to this model, the development process sped up considerably.

For real-time stuff, you could forgo Tornado all together and instead use gevent to deploy your Flask app (http://flask.pocoo.org/docs/deploying/others/#gevent), like some have done with Django and Pyramid (http://blog.abourget.net/2011/3/17/new-and-hot-part-4-pyrami...), but I haven't tried this yet.

Re: Flask 0.7 Released (Python Web Framework)

#73
post #41

Earlier quoted context omitted.

Tornado is batteries included. Flask uses Werkzeug and Jinja2 and encourages packaging extensions for localization, form processing, ORM's etc.. Flask, Werkzeug and Jinja2 are all Pocoo projects that have a good community around them and excellent documentation. Technically I would not like to argue the superiority of either, although Flask seems to fit my tastes much better. Flask's use and deployment of "magic" is…

Why would it be good to avoid passing around the request object?

Armin explains the request object here (http://flask.pocoo.org/docs/reqcontext/) and here (http://flask.pocoo.org/docs/quickstart/#id4), and the concept of "context locals" in detail here (http://werkzeug.pocoo.org/docs/local/).

Re: Flask 0.7 Released (Python Web Framework)

#74

Earlier quoted context omitted.

Could you put an example on pastebin or somewhere? I would really appreciate this.

Along the lines of http://flask.pocoo.org/docs/patterns/mongokit/ , I have a MONGODB_DATABASE setting, which is set to my normal database name. Then access the database via the connections' dictionary syntax, instead of attribute syntax (I have a helper method to make this prettier): connection[app.config['MONGODB_DATABASE']].mycollection.find_one() The unittest code just modifies the setting: import unittest def set…

Thanks a lot man. This was really useful, I am on my first steps with unittest.

Re: Flask 0.7 Released (Python Web Framework)

#75
post #72
post #39

Right now, I'm writing most of my projects in Tornado.. Not because I need the async, but because I wanted a simple web.py like format that was under active development. Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? I can understand the simplicity argument; I chose to avoid Django because it was t…

Flask is a simple web.py-like framework that is under active development, and I would argue it's one of the cleanest Python Web frameworks (if not the cleanest) out there. My current project requires real-time stuff so I started to develop it using Tornado and then decided to switch to the Quora model -- use a traditional Web framework for most things, and connect back to Tornado for the real-time stuff. Quora uses P…

BTW: Charlie Cheever, one of Quora's founders, recently said they would have considered Flask if it had been released by the time they were setting things up (http://www.quora.com/Why-did-Quora-choose-to-develop-in-Pylo...).

Re: Flask 0.7 Released (Python Web Framework)

#76
post #70

Earlier quoted context omitted.

I notice that several projects (including Flask) do not build in support for DB schema management- e.g. migrations. For those of you who are writing apps in Flask, how do you guys manage changes in DB schema ?

Flask has become my framework of choice because it's incredibly well designed, the code is clean, and also because it's decoupled from an ORM. Rails and Django emerged at a time when RDBMS ruled, and they were both built around an ORM. Now you have more database options that have less of an impedance mismatch, but because Rails and Django are so ORM-centric, forgoing the RDBMS in favor of another option means you now…

Rails and Django emerged at a time when RDBMS ruled, and they were both built around an ORM. Now you have more database options that have less of an impedance mismatch, but because Rails and Django are so ORM-centric, forgoing the RDBMS in favor of another option means you now have a framework mismatch.

And Rails & Django were (at the time) also built around a specific ORM. Compare this to Catalyst, which also came out same time as Rails & Django, was built from the ground up with an agnostic model and thus could use any ORM available or easily adapt to different data models.

Re: Flask 0.7 Released (Python Web Framework)

#77

I've used it for small side-projects and liked it. What I would like to know is how to do logging, both day-to-day ("user Joe created") and for debugging (like JSON dumps of objects). It should work both with the built-in server and with gunicorn, for deployment. I looked but wasn't able to find a solution that worked. The documentation mentioned logging facilities, but I found no working examples.

I believe that refers to the standard python "logging" module.

Right, but do I have to manually add a logging handler? Where does my logging.warn("...") end up?

Re: Flask 0.7 Released (Python Web Framework)

#78
Flask seems nice and simple until you need to access a database such as MySQL. With SQLAlchemy it seems like there's a lot more code needed just to perform simple CRUD operations, whereas Django's ORM is really simple. Is there a better alternative to SQLAlchemy? Is it possible to use Django's ORM in Flask?

Re: Flask 0.7 Released (Python Web Framework)

#79

Flask is awesome and can be easily supercharged by pairing it with Paste Deploy: http://pythonpaste.org/deploy This way you get Flask simplicity and elegance, but also you get Rails-like separation of configuration test/development/production environments. Another misconception people seem to have is that Flask means Jinja2. Fortunately that's not the case, swapping Jinja with Mako is also extremely easy. Finally, Fl…

I notice that several projects (including Flask) do not build in support for DB schema management- e.g. migrations. For those of you who are writing apps in Flask, how do you guys manage changes in DB schema ?

I don't use Flask, but sqlalchemy. If you want an orm in a flask-based app, you will most probably end up using sqlalchemy, and there is a migration tool for sqlalchemy: http://code.google.com/p/sqlalchemy-migrate/

Re: Flask 0.7 Released (Python Web Framework)

#80

Flask seems nice and simple until you need to access a database such as MySQL. With SQLAlchemy it seems like there's a lot more code needed just to perform simple CRUD operations, whereas Django's ORM is really simple. Is there a better alternative to SQLAlchemy? Is it possible to use Django's ORM in Flask?

Gonna answer this one myself: Seems http://www.sqlobject.org/ might be a good alternative.
Post reply on HN