title: Flask - 'NoneType' object is not callable
body: <p>I am working on my first Flask application. Taking some code directly out of <a href="http://flask.pocoo.org/docs/patterns/deferredcallbacks/#deferred-callbacks" rel="noreferrer">this</a>, I am trying to make sure that a value is present in the user's cookies.</p>
  
  <pre><code>def after_this_request(f):
      if not hasattr(g, 'after_request_callbacks'):
          g.after_request_callbacks = []
      g.after_request_callbacks.append(f)
      return f
  
  @app.after_request
  def call_after_request_callbacks(response):
      for callback in getattr(g, 'after_request_callbacks', ()):
          response = callback(response)
      return response
  
  @app.before_request
  def detect_unique_id():
      unique_id = request.cookies.get('unique_id')
      if unique_id is None:
          unique_id = generate_unique_id()
          @after_this_request
          def remember_unique_id(response):
              response.set_cookie('unique_id', unique_id)
      g.unique_id = unique_id
  </code></pre>
  
  <p>I keep getting this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/..../env/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
      return self.wsgi_app(environ, start_response)
    File "/..../env/lib/python2.7/site-packages/flask/app.py", line 1690, in wsgi_app
      return response(environ, start_response)
  TypeError: 'NoneType' object is not callable
  </code></pre>
  
  <p>I am trying to understand the reason for this error. Please help. </p>