On Thu, Jul 17, 2014 at 12:27:33PM -0700, Marce Romagnoli wrote:
> from api_0_0_1.models.client import db
> db.init_app(app)
>
> g.config = app.config
This works only during a request, i.e. not right now.
Not sure why you want that too. The ``g`` object is for data that needs to be
stored for the lifetime of the request context, but you can access your config
via ``current_app.config`` anyways at that time.
> return app
>
>
> if __name__ == '__main__':
> app = create_app('development')
> app.run()
>
> But I cannot read those config values from a module I use, I have the
> error: *RuntimeError: working outside of application context. *I am doing:
>
> from flask import current_app as app
> from redis import StrictRedis
>
>
> class RedisSomething():
> __redis = StrictRedis(host = app.config['REDIS_SETTINGS']['hostname'])
>
>
> Is there any way to access those same configs set when app is created?
Same thing here. You'd have to import the app itself instead of using
current_app. I recommend you execute all this code inside your app factory or
after the factory is used.
-- Markus
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.