title: Seeking enlightenment - global variables in AppEngine (aeoid.get_current_user())
body: <p>This may be a 'Python Web Programming 101' question, but I'm confused about some code in the aeoid project (<a href="http://github.com/Arachnid/aeoid" rel="nofollow noreferrer">http://github.com/Arachnid/aeoid</a>). here's the code:</p>
  
  <pre><code>_current_user = None
  
  def get_current_user():
      """Returns the currently logged in user, or None if no user is logged in."""
      global _current_user
  
      if not _current_user and 'aeoid.user' in os.environ:
          _current_user = User(None, _from_model_key=os.environ['aeoid.user'])
      return _current_user
  </code></pre>
  
  <p>But my understanding was that global variables were, ehm, global! And so different requests from different users could (potentially) access and update the same value, hence the need for sessions, in order to store per-user, non-global variables. So, in the code above, what prevents one request from believing the current user is the user set by another request? Sorry if this is basic, it's just not how i thought things worked.</p>
  
  <p>Thanks</p>