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