Flask: a micro web framework for Python
flask.pocoo.org
flask.pocoo.org
Flask embraces thread locals - Django tends to pretend they aren't necessary at the user level, even though there are a few of them lurking in the core framework. Flask's request object is thread-safe global, and Flask encourages you to put your own per-request global instances (such as a database connection which is opened at the beginning of the request and closed at the end) on the special flask.g object. I've always disliked this kind of approach because it makes it hard to run your code outside of the context of a web request (e.g. in a cron script), but Flask deals with that by providing a clever test_request_context method:
from flask import request
with app.test_request_context('/hello', method='POST'):
# now you can do something with the request until the
# end of the with block, such as basic assertions:
assert request.path == '/hello'
assert request.method == 'POST'
Using the with statement here is very smart - Flask seems to get a lot of mileage out of both context managers and decorators.I'm looking forward to seeing how Flask shapes up - it feels like a very modern attempt at a Python micro-framework, with some pleasantly unconventional ideas.
I think they are a bad idea. I love urls.py being kind of a TOC for your application. Apart from that I can see a lot of good ideas in here. Solid template and HTTP layers, signed cookies, avoiding the ORM, short lived messaging, proper __html__, simplistic URL reversal. I love the simple request object API (args, form, files).
I can see additional libraries around this core. High level forms library at least.
An ORM is tangental to Flask - there is some docs on how to use with SQLAlchemy (which also suggests WTForms for validation) but it's ORM/DB neutral, which is a good idea.
However I'm warming to the idea of avoiding an ORM completely in future projects - just use a thin layer around MySQLdb or DB of choice, like tornado.database or SQLAlchemy's query API.
edit: In response to the downvotes - it appears that it was an April Fool's joke, but because of the response he got, Armin decided to try it out for real. Yeesh.
Denied: Python Micro-Framework (http://news.ycombinator.com/item?id=1237412)
April 1st Post Mortem (http://news.ycombinator.com/item?id=1239438)
examples here: http://webpy.org/ http://sinatrarb.com/
(I really want to know - it seems very similar to Sinatra to me. What are the differences?).
Examples of mini-frameworks in various languages: http://gist.github.com/353559
Would also hope to see good support with document databases like mongodb.
(I'm not a Python hater, but I do like Ruby blocks.)
Perhaps Flash's angle could be not to shrink the minimum LOC needed, but to deliver more features per app LOC.