On Sep 18, 2008, at 5:46 AM, Adam Dziendziel wrote:
> > Hi, > > I have a column which contains XML, this XML is parsed when a record > is loaded and object attributes are populated with values from this > XML. When I set an attribute, I would like to mark the XML column > modified (in property() setter). I wouldn't need to serialize all > attributes and assign a new value to the XML column explicitly when > only a single attribute changes. This would generate too much overhead > when I set many attributes subsequently. I'd like to just make the XML > column (or the whole record) dirty, so that I'm able to serialize > attributes to XML only in before_insert/before_update handlers in a > MapperExtension. > > Is this possible with SQLAlchemy? I'm using 0.4.x. This description was very hard to parse, but I think what you're saying is an attribute changes on a *different* object somewhere, which you would like to mark the XML-holding object as dirty. To mark the object dirty you can say instance_state(myobject).modified = True , where instance_state is in sqlalchemy.orm.attributes. Theres no "dirty" flag on individual attributes, the change status is determined by the contents of the attribute. So just blanking out the XML attribute until needed is a pretty easy approach here too. Yet another option which is the most lightweight would be to use a SessionExtension with an after_flush() method that issues an UPDATE to the XML-holding column directly. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---