librelist archives

« back to archive

Re: [flask] Flask configuration best practices

Re: [flask] Flask configuration best practices

From:
Aaron Rothenberg
Date:
2012-10-18 @ 00:43
I'm also interested in this.

> Date: Wed, 17 Oct 2012 20:19:50 -0400
> From: desmond.rivet@gmail.com
> Subject: [flask] Flask configuration best practices
> To: flask@librelist.com
> 
> Hi all,
> 
> I'm wondering if there are any best practices in regards to Flask configuration.
> 
> For example, how do you guys prevent Flask plugins from stepping on
> each other's toes with respect to configuration keys?  Do you just
> make sure each plugin's config keys begins with a different string?
> 
> Is it considered bad practice to "nest" configuration,  i.e. store a
> piece of config that points to another dictionary?  Or do you guys
> prefer to keep everything flat?  Or do you guys have no opinion one
> way or the other?
> 
> At the moment I'm writing a flask application that has its own
> non-standard "plugin" structure. Each plugin can have it's own
> configuration.  I'm tempted to nest the config in the global flask
> config object to prevent conflicts, but I just wanted to see what
> everyone thought.
> 
> Thanks in advance for any advice,
> 
> Desmond
 		 	   		  

Re: [flask] Flask configuration best practices

From:
Aaron Rothenberg
Date:
2012-10-18 @ 17:02
This is not my question but your post was helpful.  As a noob   I'd like 
to seehttp://flask.pocoo.org/docs/api/#flask.Flask.extensions in action.  
This is not an answer to the question(I am brand new to Flask) but here  a
list of "necessary practices" in order to be approved by Flask(I'm 
assuming).http://flask.pocoo.org/docs/extensiondev/#approved-extensionsIt 
doesn't have anything to say about config keys. I'm planning to use the 
link loosely as a "best practices" guide.

http://flask.pocoo.org/docs/extensiondev/#approved-extensions
> Date: Thu, 18 Oct 2012 10:27:09 +0200
> From: simon.sapin@exyr.org
> Subject: Re: [flask] Flask configuration best practices
> To: flask@librelist.com
> 
> Le 18/10/2012 02:19, Desmond Rivet a écrit :
> > Hi all,
> >
> > I'm wondering if there are any best practices in regards to Flask 
configuration.
> >
> > For example, how do you guys prevent Flask plugins from stepping on
> > each other's toes with respect to configuration keys?  Do you just
> > make sure each plugin's config keys begins with a different string?
> >
> > Is it considered bad practice to "nest" configuration,  i.e. store a
> > piece of config that points to another dictionary?  Or do you guys
> > prefer to keep everything flat?  Or do you guys have no opinion one
> > way or the other?
> >
> > At the moment I'm writing a flask application that has its own
> > non-standard "plugin" structure. Each plugin can have it's own
> > configuration.  I'm tempted to nest the config in the global flask
> > config object to prevent conflicts, but I just wanted to see what
> > everyone thought.
> 
> Hi,
> 
> I’m not sure what exactly you call a "plugin", but I think that the 
> closest we have in Flask are extensions:
> 
> http://flask.pocoo.org/docs/extensions/
> http://flask.pocoo.org/extensions/
> 
> The convention for extension configuration is to use config keys with a 
> prefix based on the name of the extension. For example, Flask-SQLAlchemy 
> uses SQLALCHEMY_DATABASE_URI rather than just DATABASE_URI.
> 
> For run-time objects like a database connection pool, there is the 
> app.extensions dict:
> 
> http://flask.pocoo.org/docs/api/#flask.Flask.extensions
> 
> Cheers,
> -- 
> Simon Sapin