[Flask] SDLC configuration

Guy Matz guymatz at gmail.com
Mon Aug 8 11:31:19 EDT 2016


Thanks!   Yeah, that works when I remove the references to self, but I
don't like the idea of having to repeat that code in the definition for
each environment . . .  would be nice to have that in the super-class
(Config), but that doesn't seem to work . . .

I still don't really understand what kind of class Config is, that doesn't
use self or have the usual dunder-score methods . . .

On Sun, Aug 7, 2016 at 3:05 AM, Badri Sunderarajan <badrihippo at gmail.com>
wrote:

> 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/20160808/27f4d469/attachment.html>


More information about the Flask mailing list