Michael Bayer ha scritto: > > On Feb 25, 2007, at 9:03 AM, Manlio Perillo wrote: > >> Michael Bayer ha scritto: >>> On Feb 23, 2007, at 1:56 PM, Manlio Perillo wrote: >>> >>>> Hi again. >>>> >>>> I have an object attribute loaded via lazy loader. >>>> This object is loaded in a transaction. >>>> >>>> Then, in another transaction, I ussue an update statement (via >>>> the sql >>>> module, not using the orm), that updates the table of the main >>>> object's >>>> attribute. >>>> >>>> The problem, now, is that I want to reload this attribute. >>>> >>>> I have tried, in a separate transaction: >>>> sess.update(obj) >>>> sess.expire(obj) >>>> >>>> One problem here is that the entire object is reloaded, and I do not >>>> want this. >>> i think if you say delattr(obj, attributename), it will do a lazyload >>> on the next run. >>> >> Sorry, I have tested only sess.expire(obj). >> >> delattr(obj, attributename) does not works. >> > > OK, again, if you want the actual object that is *in* the lazy loaded > collection to be reloaded, you have to issue an expire() or refresh() > on at least that object. if the object is already in the session, > the lazy load may still fire off but will only reload the instance > that is already in the session. > > so you might want do instead do this (assuming its a lazy load > collection - modify accordingly for a scalar attribute): > > for o in myinstance.somecollection: > sess.expire(o) >
This works, thanks! However, for non scalar attribute, I would like to simply do: sess.expire(myinstance.somecollection) Regards Manlio Perillo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
