def get_from_identity(session, key, passive):
 instance = session.identity_map.get(key)
 if (instance is not None):
  state = attributes.instance_state(instance)
  if state.expired:
   if (not (passive & attributes.SQL_OK)):
    return attributes.PASSIVE_NO_RESULT
   elif (not (passive & attributes.RELATED_OBJECT_OK)):
    return instance
   try:
    state._load_expired(state, passive)
   except orm_exc.ObjectDeletedError:
    session._remove_newly_deleted([state])
    return None
  return instance
 else:
  return None

def get_from_identity ( session , key , passive ) : instance = session . identity_map . get ( key ) if ( instance is not None ) : state = attributes . instance_state ( instance ) if state . expired : if ( not ( passive & attributes . SQL_OK ) ) : return attributes . PASSIVE_NO_RESULT elif ( not ( passive & attributes . RELATED_OBJECT_OK ) ) : return instance try : state . _load_expired ( state , passive ) except orm_exc . ObjectDeletedError : session . _remove_newly_deleted ( [ state ] ) return None return instance else : return None
look up the given key in the given sessions identity map .