2 ms·
Building a flask app myself at the moment, a few (non obvious) things come to my mind : - sqlalchemy integration by "hand" (not using flask-sqlalchemy module)
by bsaul 13y ago
Building a flask app myself at the moment, a few (non obvious) things come to my mind :
- sqlalchemy integration by "hand" (not using flask-sqlalchemy module) : managing sqlalchmey session scope and lifecycle "in the middle" of the flask request lifecycle
- celery integration "by hand" : flask app configuration reuse by celery tasks.
- google app engine deployment
- uwsgi + nginx deployment
- user credential + session management.
+ a chapter on good REST JSON API architecture (eg : returning both HTTP error code along with JSON data).
- rpicard 13y agoI appreciate the suggestions. Since it's something I'll want to consider writing about, why are you interested in the "by hand" integrations rather than using the Flask plugins?
- bsaul 13y agoBecause you really need to understand how things work to debug them sometimes. Personal example : flask-sqlalchemy binds the session lifecycle to the flask request lifecycle. 1 session <-> 1 request. Now i've got celery tasks, and they're also using sqlalchemy, and all of the sudden, my celery tasks running on the same thread seem to keep the same session object for different tasks. One solution (IIRC) was to create a new "fake" request context for each task, and then let sqlalchemy session bind to that fake request. If i just plugged the flask-sqlalchemy module, i wouldn't have even known about session scopes, and would have looked at the celery bug with a blank stare. Since flask is a micro framework it lets you customize those kind of things. But more importantly, it lets you LEARN about the issues in the first place. I think that's one of the major benefits of dealing with micro frameworks.
- rpicard 13y agoThat's very interesting. I'm making a note of this for inclusion in the book.