Can you give an example of a forwards-compatible way to modify an attribute to mark the instance dirty without creating actual net changes? SA seems quite good at detecting my tricks.
On Oct 27, 6:41 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Oct 27, 2010, at 11:43 AM, Nikolaj wrote: > > > I have a mapped class called Widget, with an uninstrumented attribute > > called 'owner' (i.e. it does not have a column representation). Widget > > has a MapperExtension with a before_update() method that runs a couple > > of queries using connection.execute() and sets some attributes on the > > instance. > > > I would like Widget.owner to behave like an instrumented attribute in > > the sense that modifying it forces a MapperExtension.before_update() > > run at flush-time. Is that possible? > > > Alternatively, is there a way to force a before_update() run by > > marking an instance as dirty (possibly by modifying attributes without > > actual net changes)? In that case I could make Widget.owner into a > > property and mark the instance dirty in the setter. > > that last idea would work and would be forwards-compatible. Otherwise you'd > need to emit a modified event to instance_state(myobject) which isn't public > API. > > > > > Thanks, > > > N > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalch...@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.