title: Accessing User Object in Function for Flask Limiter Returns Context Error
body: <p>I'm using the Flask-limiter extension to limit the number of page requests for a certain route (unless they are logged in as administrator).  I am using the Flask-Stormpath extension to manage my user authentication.</p>
  
  <p>For some reason, my existing function returns this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "index.py", line 772, in &lt;module&gt;
      @limiter.limit("20/hour", exempt_when=admin_conditions())
    File "index.py", line 114, in admin_conditions
      if current_app.user.is_authenticated():
    File "c:\Python27\lib\site-packages\werkzeug\local.py", line 338, in __getattr
  __
      return getattr(self._get_current_object(), name)
    File "c:\Python27\lib\site-packages\werkzeug\local.py", line 297, in _get_curr
  ent_object
      return self.__local()
    File "c:\Python27\lib\site-packages\flask\globals.py", line 34, in _find_app
      raise RuntimeError('working outside of application context')
  RuntimeError: working outside of application context
  </code></pre>
  
  <p>here is my code:</p>
  
  <pre><code># Rate Limiting function
  def admin_conditions():
      if user.is_authenticated():
          group_list = []
          for group in user.groups:
              group_list.append(group.name)
  
          if not group_list:
              return(False)
          else:
              if group_list[0] == "admins":
                  return(True)
              else:
                  return(False)
      else:
          return(False)
  
  # route
  @limiter.limit("20/hour", exempt_when=admin_conditions())
  </code></pre>
  
  <p>I read that the admin_conditions function is called in the <a href="http://flask-limiter.readthedocs.org/en/stable/#keyfunc-customization" rel="nofollow">request context</a> by flask-limiter, but I don't understand how to access the user object from there.  Any ideas what's going on? </p>