4 ms·
A couple other things I'd add to this good article: - I took a couple of good things from Django's manage.py by using Flask-Script. It looks like [1] - I'm no
by mattdeboard 13y ago
A couple other things I'd add to this good article:
- I took a couple of good things from Django's manage.py by using Flask-Script. It looks like [1]
- I'm not sure if there's a better way of doing this, but I really want to be able to swap out configurations based on which environment I'm using. I think I've forced some Django structure onto Flask, but that said, I dynamically load in a `settings` object and use that to configure my `app` object. I use something like [2]. Just looking over it again I think I have some extraneous code in there but I'm tired. It works pretty well, so far.
- Flask-SQLAlchemy has some good stuff too but I'm not entirely sold on using it. I'm using it on one project, but not the other. I don't miss it when I don't have it.
1. https://gist.github.com/mattdeboard/5872584 https://gist.github.com/mattdeboard/5872584
2. https://gist.github.com/mattdeboard/3cbe5395052128e60328 https://gist.github.com/mattdeboard/3cbe5395052128e60328
- mattupstate 13y agoGood call on the Flask-Script mention. I will add a note about that. As far as configuration based on environment goes, I really dislike environment based configuration in my project repository. So I use Flask's instance folder functionality: http://flask.pocoo.org/docs/config/#instance-folders http://flask.pocoo.org/docs/config/#instance-folders This file can be used to configure the app based on its environment wether it be local development or my production environment. The shared factory method attempts to load this file and fails silently if it does not exist. Regarding your SQLAlchemy comment, well...thats just not really something to add to the article now, is it? ;)
- mattdeboard 13y agoYeah but how would this solve having identical app installations in dev, prod and staging?
- mattupstate 13y agoThe settings.cfg file that I place in the instance folder is generally placed on the server during deployment. Any values in this file will override defaults. I generally do this with Chef or Fabric. Perhaps that answers your question
- hartror 13y agoNot sold on using it? What are the reasons?
- mattdeboard 13y agoWell, I just haven't had a TON of use for it yet. I'm a little wary that I'll need to work around leaky abstractions. I'm not poo-pooing it, just ... cynical.
- jp_sc 13y agoFlask-SQLAlchemy is a thin layer over SQLAlchemy, so the risk of leakage is low. That said, what I don't like is that it's too coupled with Flask, so I prefer to use my own version: https://github.com/lucuma/orm https://github.com/lucuma/orm
- mattdeboard 13y agoNice, thanks for the link. I'll look into this next week.