def make_transient_to_detached(instance):
 state = attributes.instance_state(instance)
 if (state.session_id or state.key):
  raise sa_exc.InvalidRequestError('Given object must be transient')
 state.key = state.mapper._identity_key_from_state(state)
 if state._deleted:
  del state._deleted
 state._commit_all(state.dict)
 state._expire_attributes(state.dict, state.unloaded)

def make_transient_to_detached ( instance ) : state = attributes . instance_state ( instance ) if ( state . session_id or state . key ) : raise sa_exc . InvalidRequestError ( 'Given object must be transient' ) state . key = state . mapper . _identity_key_from_state ( state ) if state . _deleted : del state . _deleted state . _commit_all ( state . dict ) state . _expire_attributes ( state . dict , state . unloaded )
make the given transient instance :term:detached .