def set_transaction(self, session, transaction):
        # type: (Session, RepositoryTransaction) -> None
        """
        :param:session: :class:`sqlalchemy.orm.session.Session` instance
        :param:transaction: :class:`RepositoryTransaction` instance
        """
        if isinstance(session, sa.orm.scoped_session):
            session = session()

        s_id = id(session)
        self.transactions[s_id] = (weakref.ref(session), transaction)
def set_transaction ( self , session , transaction ) : if isinstance ( session , sa . orm . scoped_session ) : session = session ( ) s_id = id ( session ) self . transactions [ s_id ] = ( weakref . ref ( session ) , transaction )
:param:session: :class:`sqlalchemy.orm.session.Session` instance
        :param:transaction: :class:`RepositoryTransaction` instance