def __getattr__(self, name): with db_session() as session: if sessionmaker.object_session(self.record) != session: session.add(self.record) session.refresh(self.record) val = getattr(self.record, name) return val
def __getattr__(self, name): with _autoclosing_session(self.sessionmaker) as session: if sessionmaker.object_session(self.record) != session: session.add(self.record) session.refresh(self.record) val = getattr(self.record, name) return val
def __setattr__(self, name, value): with db_session() as session: if sessionmaker.object_session(self.record) != session: session.add(self.record) session.refresh(self.record) setattr(self.record, name, value) session.merge(self.record) session.commit()
def __setattr__(self, name, val): with _autoclosing_session(self.sessionmaker) as session: if sessionmaker.object_session(self.record) != session: session.add(self.record) session.refresh(self.record) setattr(self.record, name, val) session.merge(self.record) session.commit() return val
def __str__(self): with db_session() as session: if sessionmaker.object_session(self.record) != session: session.add(self.record) session.refresh(self.record) return str(self.record)