Kevin Deenanauth <kdeenanauth <at> pegasys.cc> writes:

> 
> 
> This code:
> 
> session = objectstore.get_session()
> print session.dirty
> 
> ...gives me a list of what objects are going to be updated.  How do I find out
> what exact attributes changed?
> 
> Thanks for Sqlalchemy!  I came from the SQLObjects side and this stuff is much
> more robust
> -Kevin
> 


I've found one solution:
session = objectstore.get_session()

for obj in session.dirty:
    for col in obj.mapper.table.columns:
        prop = obj.mapper._getpropbycolumn(col, False)
        if prop is None:
            continue
        history = prop.get_history(obj, passive=True)
        a = history.added_items()
        if len(a):
            print 'changed:',type(prop),prop.key,a

It does feel hackish, but it works.  If anyone knows a better solution, let me
know! =)




_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to