[Flask] SDLC configuration
Badri Sunderarajan
badrihippo at gmail.com
Fri Aug 5 08:24:54 EDT 2016
Looking at your pastebin code, it seems like you're calling the
load_active_projects() function while /defining/ the classes, rather
than when you're actually using them. So the Python interpreter will be
executing load_active_projects for each of (ProductionConfig, DevConfig,
QaConfig) /before/ it actually uses the DevConfig class.
You can confirm this by checking the value of app.config['FLOWBOT_ENV']
from your main app.
I don't know how exactly Flask's config.from_object works, but I think
what you want to do would be more like:
class DevConfig(Config):
FLOWBOT_ENV = 'dev'
# ... other config goes here ...
def __init__(self):
self.PROJECTS = load_active_projects(self.FLOWBOT_ENV)
self.SCHEDULED_JOBS = load_active_scheduled_jobs(FLOWBOT_ENV)
...so that your load functions are only called when the class is
actually instantiated (used).
Sorry I can't into it properly at the moment—tell me how it goes and
I'll check back tomorrow when I have more time ;)
—Badri/Hippo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160805/770288bb/attachment.html>
More information about the Flask
mailing list