Thank you but when I try downloading http://www.sistechnology.com/o2rm/o2rm0224.tar.bz2, I get a 404 not found :-(
2007/6/21, svilen <[EMAIL PROTECTED]>: > > > > I'm working in a GUI project and use the SQLAlchemy for ORM. > > > Can anyone tell me how to catch a attribute changed event in > > > SQLAlchemy so that application can update the UI automaticly. > > > Thank you. > > > > > > -- > > > XUE Can > > > > This may be more of a Python question, because it is not > > specifically related to data persistence. > > > > Mapper Extensions: > > http://www.sqlalchemy.org/docs/adv_datamapping.html#advdatamapping_ > >extending can help if you want to catch a hook before a class > > instance is updated in the database. But if you want to catch the > > moment when the attribute is changed in memory, consider the > > possibility that this is not in sqlalchemy's scope. > > All mapped attributes of any class with SA mapper, become > InstrumentedAttributes, which is a descriptor catching those > get/set/s. So the exact moment IS catchable, as long as one somehow > attaches himself on these InstrumentedAttributes __get__/ __set__. > > There are 2 types of events here to consider: change coming from > outside (the UI user typed something) and change coming from inside > (data loaded from DB). > > Changes coming from outside could be catchable via overloading > __setattr__ and/or InstrumentedAttr's __set__; changes coming from > inside mostly go via object.__dict__[attrname]. > > i have implemented such catcher, basicaly it replaces the __dict__ of > the mapped objects with a class that simulates a dict and gives > control over set/get/del. beware, it is slow. > see sa2static.py in http://www.sistechnology.com/o2rm/o2rm0224.tar.bz2 > > i didn't answered before because my needs of the above catcher are far > more trickier than just UI-event setattr dispatch, so i thought there > might be something easier way within SA itself. > > As i see it, u want Observers that listen to changes in particular > attributes - or any attributes. > > svil > > > > -- 薛粲 有耕耘方能有收获,愿能与您顺心携手共成长。 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---