the “user” backref here is a relationship() like any other, just specify
Address.user as the target of the event.

Cyril Scetbon <[email protected]> wrote:

> Hi,
> 
> Is there a way to add an event listener on a backref ?
> 
> I have something like :
> 
> class User(Base):
> 
>     
> __tablename__ = 'user'
> 
>     
> id = Column(Integer, primary_key=True)
> 
>     
> name = Column(String)
> 
> 
>     
> addresses = relationship("Address", backref="user")
> 
> 
> 
> class Address(Base):
> 
>     
> __tablename__ = 'address'
> 
>     
> id = Column(Integer, primary_key=True)
> 
>     
> email = Column(String)
> 
>     
> user_id = Column(Integer, ForeignKey('user.id'))
> 
> 
> I'd like to do add an action when a dev set the attribute Address.user.
> 
> -- 
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to