@staticmethod
def add_session(fact, session, orm_classes):
    """Attach the session to the factory"""
    fact._meta.sqlalchemy_session = session
    fact._meta.sqlalchemy_session_persistence = 'flush'
    if isinstance(fact._meta.model, str):
        try:
            fact._meta.model = orm_classes[fact._meta.model]
        except KeyError:
            raise KeyError(
                'ORM Class not found matching %s. Check mapping.yml' % fact
                ._meta.model)
    return fact
