示例#1
0
 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
示例#2
0
    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
示例#3
0
 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()
示例#4
0
    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
示例#5
0
    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
示例#6
0
 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)