from sqlalchemy.orm import Session
s = Session()
s.autoflush = False
s.autocommit = False
p1 = s.query(Person).first()
print p1 #prints 'Ivan Petrov', correct name of a person #1
p1.name = 'John Smith' #change the person's name
p2 = s.query(Person).first()
print p2 #prints 'John Smith', but the object wasn't flushed yet.
問題は、この状況を正しく処理するにはどうすればよいかということです。私がそう言うまでは、セッション (および p2) に影響を与えないように p1 を変更する必要があります。