On Wed, Jul 3, 2013 at 7:30 PM, Michael Bayer <mike...@zzzcomputing.com>wrote:

> @event.listens_for(Gadget, "before_insert")
> def before_gadget(mapper, connection, target):
>     target.machine_id = target.widget.machine_id
>
>
> 2. when widget is updated, gadgets need new machine_id, here UPDATE is
> probably best since the Gadget might not be part of the flush:
>
> @event.listens_for(Widget, "after_update")
> def after_widget(mapper, connection, target):
>     connection.execute(
>         Gadget.__table__.update().
>             values(machine_id=target.machine_id).
>             where(Gadget.widget_id == target.widget_id)
>

That works for me, thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to