Exemple #1
0
class SessionManager:
    def __init__(self, entity):
        self.entity = entity
        self.session = Session()
        if not self.session.object_session(self.entity):
            self.session.add(self.entity)

    def __enter__(self):
        return self.session

    def __exit__(self, exc_type, exc_value, exc_traceback):
        if exc_value:
            self.session.expunge(self.entity)
            return False
        self.session.commit()
        return True
Exemple #2
0
def save(streamsets: StreamSets):
    if not Session.object_session(streamsets):
        Session.add(streamsets)
    Session.commit()
Exemple #3
0
def save(source_: Source):
    if not Session.object_session(source_):
        Session.add(source_)
    Session.commit()
Exemple #4
0
def save_auth_token(token: AuthenticationToken):
    if not Session.object_session(token):
        Session.add(token)
    Session.commit()
Exemple #5
0
def save(destination_: HttpDestination):
    if not Session.object_session(destination_):
        Session.add(destination_)
    Session.commit()
Exemple #6
0
def save(entity: Entity):
    if not Session.object_session(entity):
        Session.add(entity)
    Session.commit()