Hi, everyone!
                   I am having a little issue with my Flask app.

I am using a create_app method in order to create my app instance from 
Flask(), there I set all the configs, and return app so then I can run it, 
like this:

*__init__.py*
def create_app(config_name):
    """
    Generate app based on Flask instance.

    :type config_name: string
    :param config_name: Config Type (i.e. development, testing, production, 
default).

    :rtype: Object
    :return: Flask Object.
    """
    app = Flask(__name__)

    # Load generic configs
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    # Load specific and sensitive configs
    app.config.from_object(iconfig[config_name])

    # Register Blueprint
    from api_0_0_1 import api as api_0_0_1_blueprint
    app.register_blueprint(api_0_0_1_blueprint, url_prefix = '/0.0.1/<cc>')

    from api_0_0_1.models.client import db
    db.init_app(app)

    g.config = app.config
    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?

Hope I was clear.


-- 
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.

Reply via email to