title: Flask, Blueprint, current_app
body: <p>I am trying to add a function in the Jinja environment from a blueprint (a function that I will use into a template).</p>
  <p><strong>Main.py</strong></p>
  <pre><code>app = Flask(__name__)
  app.register_blueprint(heysyni)
  </code></pre>
  <p><strong>MyBluePrint.py</strong></p>
  <pre><code>heysyni = Blueprint('heysyni', __name__)
  @heysyni.route('/heysyni'):
      return render_template('heysyni.html', heysini=res_heysini)
  </code></pre>
  <p>Now in <strong>MyBluePrint.py</strong>, I would like to add something like :</p>
  <pre><code>def role_function():
      return 'admin'
  
  app.jinja_env.globals.update(role_function=role_function)
  </code></pre>
  <p>I will then be able to use this function in my template. I cannot figure out how I can access the application since</p>
  <pre><code>app = current_app._get_current_object()
  </code></pre>
  <p>returns the error:</p>
  <pre><code>working outside of request context
  </code></pre>
  <p>How can I implement such a pattern ?</p>