Hi, I spent the weekend learning flask and really love it. I have ported a small django app I have developed to flask, and I really love the experience and the result. The only thing I am missing is a config object. Or a standard way how to do app configuration. Any plans on integrating a config object? Best regards and many thanks for flask, Oliver
Hi,
On 2010-05-16 10:31 PM, Oliver Andrich wrote:
> Any plans on integrating a config object?
Yes and no. I do plan to have configuration attached to the application
in a future release, but for different reasons than you might think.
The best solution for config handling is probably this one here (before
and after config attachment integration):
http://flask.pocoo.org/snippets/2/
What the config integration in Flask would do is to move some of the
application attributes like secret_key into the config so that they can
be configured from a separate file. But in terms of looking up the
config, it probably won't become any more advanced than what a config
module does.
Certainly not a complex solution like ConfigObj or ZCML.
Regards,
Armin
You can create a config.py in the root directory of your application. import config Then you can config.DATABASE config.DEBUG -- Thadeus On Sun, May 16, 2010 at 3:31 PM, Oliver Andrich <oliver@2pxnr.de> wrote: > Hi, > > I spent the weekend learning flask and really love it. I have ported a small > django app I have developed to flask, and I really love the experience and > the result. The only thing I am missing is a config object. Or a standard > way how to do app configuration. > > Any plans on integrating a config object? > > Best regards and many thanks for flask, > Oliver >
2010/5/16 Thadeus Burgess <thadeusb@thadeusb.com> > You can create a config.py in the root directory of your application. > > import config > > Then you can > > config.DATABASE > config.DEBUG > > Yes, this is the obvious solution. But I would love something that works a bit like the session or request magic, and which can be used inside modules without import stuff. But may be I am still to big-framework-minded. Cheers, Oliver
You can just import the config anywhere - it doesn't have to be a
thread local object like request or g.
Another technique I use is to have the default settings in config, and
import a "local_config" module inside it with whatever local settings.
You keep the config.py module in your repo, and the local_config is
just added with the settings you need for your local distribution.
For example, at the bottom of config.py:
try:
from local_config import *
except ImportError:
pass
On 16 May 2010 22:08, Oliver Andrich <oliver@2pxnr.de> wrote:
> 2010/5/16 Thadeus Burgess <thadeusb@thadeusb.com>
>>
>> You can create a config.py in the root directory of your application.
>>
>> import config
>>
>> Then you can
>>
>> config.DATABASE
>> config.DEBUG
>>
>
> Yes, this is the obvious solution. But I would love something that works a
> bit like the session or request magic, and which can be used inside modules
> without import stuff. But may be I am still to big-framework-minded.
>
> Cheers,
> Oliver
>
>