Python SQLAlchemy attribute-events - How to check oldvalue equals NO_VALUE?
<p>The <a href="http://docs.sqlalchemy.org/en/latest/orm/events.html#attribute-events" rel="nofollow">official documentation</a> of SQLAlchemy states:</p>

<blockquote>
  <p>oldvalue â the previous value being replaced. This may also be the
  symbol <code>NEVER_SET</code> or <code>NO_VALUE</code>. If the listener is registered with
  <code>active_history=True</code>, the previous value of the attribute will be
  loaded from the database if the existing value is currently unloaded
  or expired.</p>
</blockquote>

<pre><code>from sqlalchemy import event

# standard decorator style
@event.listens_for(SomeClass.some_attribute, 'set')
def receive_set(target, value, oldvalue, initiator):
    "listen for the 'set' event"

    # ... (event handling logic) .
</code></pre>

<p>My problem is how can I check the old value equals the symbol <code>NO_VALUE</code>?</p>

<p>M use <code>if oldvalue == symbol(NO_VALUE)</code>  but it gives me error.</p>

<blockquote>
  <p>TypeError: 'module' object is not callable</p>
</blockquote>

<p>use </p>

<pre><code>from sqlalchemy.orm.base import NO_VALUE
if oldvalue is NO_VALUE:
    //login here
</code></pre>

<p>works for me </p>

python sqlalchemy flask-sqlalchemy