title: AttributeError: '_AppCtxGlobals' object has no attribute 'user' in flask using g
body: <p>i have many .py file in insidemyapp</p>
  
  <pre><code>@def_app.before_request
  def before_request():
      if 'user' in session:
          if session['type']=='rest':
              try:
                  r=query_db('select email,name,r_area,city,mobile_no,r_image,r_id from rest_user where email =%s',[session['user']])
                  if r:
                      for i in r:
                          g.user=i
                          break
              except:
                  pass
          else:
              try:
                  r= query_db('select email,name,street,city,mobile_no,image from r_users where email = %s',[session['user']])
                  if r:
                      for i in r:
                          g.user=i
                          print(g.user)
                          break
              except:
                  pass
  </code></pre>
  
  <p><strong>when i use g.user in other py file we get an error (AttributeError: '_AppCtxGlobals' object has no attribute 'user')</strong></p>
  
  <p>this happen when i convert my single app file into multiple using blueprint</p>
  
  <p><strong>error result</strong></p>
  
  <pre><code>  Traceback (most recent call last):
    File "C:\Python33\lib\site-packages\flask\app.py", line 1836, in __call__
      return self.wsgi_app(environ, start_response)
    File "C:\Python33\lib\site-packages\flask\app.py", line 1820, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File "C:\Python33\lib\site-packages\flask\app.py", line 1403, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Python33\lib\site-packages\flask\_compat.py", line 33, in reraise
      raise value
    File "C:\Python33\lib\site-packages\flask\app.py", line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File "C:\Python33\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "C:\Python33\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Python33\lib\site-packages\flask\_compat.py", line 33, in reraise
      raise value
    File "C:\Python33\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File "C:\Python33\lib\site-packages\flask\app.py", line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "C:\Users\mehrab alam\Google Drive\organized\myapp\insidemyapp\profile.py", line 25, in profile
      print(g.user)
    File "C:\Python33\lib\site-packages\werkzeug\local.py", line 338, in __getattr__
      return getattr(self._get_current_object(), name)
  AttributeError: '_AppCtxGlobals' object has no attribute 'user'
  </code></pre>
  
  <p>please help..............</p>