I am trying to access the configuration of an access application inside the authorisation.py drawing, which is in the api package. I initialize the project in __init__.py , which is used in authorisation.py .
__ __ INIT. RU
from flask import Blueprint api_blueprint = Blueprint("xxx.api", __name__, None) from api import authorisation
authorization.py
from flask import request, jsonify, current_app from ..oauth_adapter import OauthAdapter from api import api_blueprint as api client_id = current_app.config.get('CLIENT_ID') client_secret = current_app.config.get('CLIENT_SECRET') scope = current_app.config.get('SCOPE') callback = current_app.config.get('CALLBACK') auth = OauthAdapter(client_id, client_secret, scope, callback) @api.route('/authorisation_url') def authorisation_url(): url = auth.get_authorisation_url() return str(url)
I get RuntimeError: working out of application context
I understand why this is so, but what is the correct way to access these configuration settings?
---- ---- Update Temporary, I did it.
@api.route('/authorisation_url') def authorisation_url(): client_id, client_secret, scope, callback = config_helper.get_config() auth = OauthAdapter(client_id, client_secret, scope, callback) url = auth.get_authorisation_url() return str(url)
flask
Chirdeep Tomar Aug 13 '13 at 16:39 2013-08-13 16:39
source share