code: def _get_real_user(user, anon_user=None):
      
      if hasattr(user, "_get_current_object"):
          # this is a proxy
          user = user._get_current_object()
      if callable(user):
          # this is a function
          user = user()
      if anon_user and isinstance(user, anon_user):
          return None
      return user
docs: Given a "user" that could be:
  
      * a real user object
      * a function that returns a real user object
      * a LocalProxy to a real user object (like Flask-Login's ``current_user``)
  
      This function returns the real user object, regardless of which we have.