title: How to share object between blueprint in Flask
body: <p>I have two blueprints, such as <code>auth</code> and <code>sprints</code>, the structure is as follows:</p>
  
  <pre><code>auth
      __init__.py
      views.py
      forms.py
  sprints
      __init__.py
      views.py
      forms.py
  </code></pre>
  
  <p>I want to share <code>api</code> object after login successfully</p>
  
  <pre><code>@auth.route('/login', methods=['GET', 'POST'])
  def login():
      form = LoginForm()
      if form.validate_on_submit():
          try:
              jira_url = app.config["JIRA_URL"]
              app_id = app.config["JIRA_APPID"]
              api = GreenHopper(options={"server": jira_url, "appid": 37},
                                basic_auth=(form.username.data, form.password.data))
              g.api = api
          except JIRAError:
              api = None
          ...
          ...
          return redirect(request.args.get('next') or url_for('scrumworks.index'))
      return render_template('auth/login.html', form=form)
  </code></pre>
  
  <p>On the <code>sprints</code> blueprint, I want to get the <code>api</code> object like codes below:</p>
  
  <pre><code>@scrumworks.route("/sprints")
  @login_required
  def show_sprints():
      if current_user.admin:
          sprints = g.api.sprints(37)
          return render_template("scrumworks/sprints.html")
      else:
        flash("Only admin users can access this page")
         return redirect(url_for(".index"))
  </code></pre>
  
  <p>When the codes run, it will complain <strong>AttributeError: '_AppCtxGlobals' object has no attribute 'api'</strong>. </p>
  
  <p>It seems the life cycle of <code>g</code> is per request, not global, so I can't store <code>api</code> in <code>g</code></p>
  
  <p>Another choice is <code>session</code>, but the <code>api</code> object cannot be serializable, so it can't be stored in <code>session</code>, what should I do next?</p>
  
  <p>Any ideas? Thanks :-)</p>