title: Flask sqlalchemy check whether object in db.session and ready for commit
body: <p>I have objects which are newly created. I would like to know how can check whether current session has that object or not?</p>
  
  <p>Something like this:</p>
  
  <pre><code>user = User(...)
  ....
  db.session.add(user)
  ...
  if db.session.has_object(user):
      &lt;process further&gt;
  </code></pre>
  
  <p>Is something like this possible?</p>
  
  <p>Also, I would like to create after_request for my flask instance so that instead of bothering about commit, it will allow me to only check whether the db.session is ready for commit or not. If it is then execute db.session.commit().</p>
  
  <p>Something like this:</p>
  
  <pre><code>@app.after_request
  def after_request(response):
      if db.session.is_ready():
          db.session.commit()
  </code></pre>