Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Justin Hunthrop
    @jhunthrop
    Hello
    using flask-empty, what is the best way to access the app config from a registered blueprint?
    I'm registering an extension (flask-security) and I cannot seem to access it from a blueprint.
    Italo Maia
    @italomaia
    Hello @jhunthrop
    kind of late, but, you could access the config object from current_app
    Amer Grgic
    @agrgic
    @italomaia you say to use current_app but how?
    Italo Maia
    @imaia
    hello @agrgic
    what do you mean?
    Amer Grgic
    @agrgic
    never mind I found it
    so you can get it from current_app.config['YOURVAR']
    :-)
    Amer Grgic
    @agrgic
    @imaia just a quick question I have an app that has a views.py and a controllers.py, and I can use current_app in the views.py but not in controllers.py, any idea?
    it says I'm outside of application context
    Italo Maia
    @imaia
    it depends on how you're calling controllers
    if your calling it from your view, current_app should be available
    Amer Grgic
    @agrgic
    yeah I have imported them into views
    hm
    Italo Maia
    @imaia
    code sample, pls
    Amer Grgic
    @agrgic
    ok second
    Italo Maia
    @imaia
    current_app is not available in the module context
    Amer Grgic
    @agrgic

    RuntimeError: Working outside of application context.

    This typically means that you attempted to use functionality that needed
    to interface with the current application object in a way. To solve
    this set up an application context with app.app_context(). See the
    documentation for more information.

    that's what it does say, that's true
    Italo Maia
    @imaia
    that piece of code is evaluated when you import controllers
    which is not within the application context
    don't do it like that
    setup configuration in the config module
    Amer Grgic
    @agrgic
    well I did setup my configuration in config.py
    if that's what you mean
    but I think I know what's going on
    because if I import the controllers after app = Blueprint etc.
    it works
    never mind my comment above, that's not true
    :-)
    so ok, I have a TWILIO_NR setup in my Dev class in config.py, how would I call it in my views.py and controllers.py?
    Amer Grgic
    @agrgic
    @imaia
    Italo Maia
    @imaia
    current_app.config["TWILIO_NR"]
    Amer Grgic
    @agrgic
    Yeah, but that does not work in my controllers.py @imaia
    Because of the error above, maybe im missing something, an import or something
    Amer Grgic
    @agrgic
    grr :(
    Amer Grgic
    @agrgic
    any ideas, I'm kind of running out of options @imaia @italomaia