コード例 #1
0
ファイル: repository.py プロジェクト: anodot/daria
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
コード例 #2
0
def save(streamsets: StreamSets):
    if not Session.object_session(streamsets):
        Session.add(streamsets)
    Session.commit()
コード例 #3
0
def save(source_: Source):
    if not Session.object_session(source_):
        Session.add(source_)
    Session.commit()
コード例 #4
0
ファイル: repository.py プロジェクト: anodot/daria
def save_auth_token(token: AuthenticationToken):
    if not Session.object_session(token):
        Session.add(token)
    Session.commit()
コード例 #5
0
ファイル: repository.py プロジェクト: anodot/daria
def save(destination_: HttpDestination):
    if not Session.object_session(destination_):
        Session.add(destination_)
    Session.commit()
コード例 #6
0
ファイル: repository.py プロジェクト: anodot/daria
def save(entity: Entity):
    if not Session.object_session(entity):
        Session.add(entity)
    Session.commit()