Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-24 Thread Jonathan Vanasco
I had a similar needs with generating diffs for tracking revision history a while back I ended up pushing everything into a mixin class. It worked a little like this... class MutatedChecknObject(object): def generate_diff(self): insp = sqlalchemy_inspect(self)

Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-24 Thread Daniel Grace
The problem I was encountering is that history doesn't make it easy to differentiate between collections and non-collections very well: inspect(obj).attrs.intcolumn.history.unchanged returns return [intval], rather than intval. inspect(obj).attrs.children.history.unchanged returns [childobj]

Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-24 Thread Michael Bayer
On Oct 24, 2013, at 4:40 PM, Daniel Grace thisgenericn...@gmail.com wrote: The problem I was encountering is that history doesn't make it easy to differentiate between collections and non-collections very well: inspect(obj).attrs.intcolumn.history.unchanged returns return [intval],

[sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-23 Thread Daniel Grace
I have a situation where an object in the ORM performs some calculations and other assorted checks. One of these situations is checking to see the difference between the original value of an attribute and the current value -- in particular, some of the validation going on should prohibit a

Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-23 Thread Michael Bayer
On Oct 23, 2013, at 8:06 PM, Daniel Grace thisgenericn...@gmail.com wrote: I have a situation where an object in the ORM performs some calculations and other assorted checks. One of these situations is checking to see the difference between the original value of an attribute and the