[Flask] SDLC configuration
Badri Sunderarajan
badrihippo at gmail.com
Sun Aug 7 03:05:33 EDT 2016
You're welcome!
Yeah, I just tried it and realised: the __init__ and __new__ functions
don't work config files. I think you'll have to fall back to doing
something like
class DevConfig(Config):
FLOWBOT_ENV = 'dev'
# ... other config ...#
# Only do the loading if FLOWBOT_ENV actually matches
if os.environ.get('FLOWBOT_ENV', None) == FLOWBOT_ENV:
self.PROJECTS = load_activee_projects(self.FLOWBOT_ENV)
self.SCHEDULED_JOBS = load_active_scheduled_jobs(FLOWBOT_ENV)
...which checks the actual FLOWBOT_ENV environment variable to decide
whether to load it or not. If-statements do work there, even though the
init functions don't. While not a very pretty solution, it'll prevent
against unnecessary loading of files. Do let me know if you think of
anything better, though!
—Badri/Hippo
On 08/06/2016 12:45 AM, Guy Matz wrote:
> You're totally right! Thanks! Unfortunately, it doesn't look like
> the Config as outlined in the flask docs
> <http://flask.pocoo.org/docs/0.11/config/#configuring-from-files> allow for
> an __init__, but I could totally be wrong since I don't understand
> what those classes are in that documentation that don't contain a
> "self". Any ideas?
>
> Much appreciated!!
> regards,
> Guy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160807/fcc80d31/attachment.html>
More information about the Flask
mailing list