'Returns instance and constraint of if-match criterion if present.
Checks the context associated with the session for compare-and-swap
update revision number constraints. If one is found, this returns the
instance that is constrained as well as the requested revision number
to match.'

def _get_constrained_instance_match(self, session):

    context = session.info.get('using_context')
    criteria = (context.get_transaction_constraint() if context else None)
    if (not criteria):
        return (None, None)
    match = criteria.if_revision_match
    mmap = standard_attr.get_standard_attr_resource_model_map()
    model = mmap.get(criteria.resource)
    if (not model):
        msg = _('Revision    matching    not    supported    for    this    resource')
        raise exc.BadRequest(resource=criteria.resource, msg=msg)
    instance = self._find_instance_by_column_value(session, model, 'id', criteria.resource_id)
    return (instance, match)
