title: Where do I put my blueprint before_request
body: <p>So I have the before request routing for my user module. But now I want to access g.users from other blueprints as well. I found the only way to do it, is to copy the code below to every single blueprint.</p>
  
  <p>I tried putting it in my app.py for @app.before_request, but then you have errors because you have to import session, g, User, and then still you get _requestglobal errors in other places.</p>
  
  <pre><code>@app.before_request
  def before_request():
    g.user = None
    if 'user_id' in session:
      g.user = User.query.get(session['user_id']);
  </code></pre>
  
  <p>What's the best place to put it?</p>
  
  <p>I get a lot of:</p>
  
  <pre><code>AttributeError: '_RequestGlobals' object has no attribute 'user'
  </code></pre>