Hello everyone! I have an application with Users and UserGroups... The users have certain permissions to do stuff in the application depending on the UserGroup they belong to. The relationship is as follows:
-------------------------------------- class User(BaseClass.BaseClass, Database.Base): __tablename__ = "users" _firstName = Column("first_name", String(50), key="fistName") _lastName = Column("last_name", String(50), key="lastName") _userName = Column("user_name", String(50), unique=True, nullable=False) _password = Column("password", String(64), nullable=False) _userGroupId = Column("user_group_id", Integer, ForeignKey("user_groups.id"), key="userGroupId") _userGroup = relationship("UserGroup", uselist=False, backref=backref("_users", collection_class=set )) class UserGroup(BaseClass.BaseClass, Database.Base): """Represents a group of users with the same features""" __tablename__ = "user_groups" _name = Column("name", String(50)) _permissions = Column("attach_posts", CharSeparatedStrings.CharSeparatedStrings(), key="attachPosts") #_users: Backref from User -------------------------------------- Let's say an administrator unassigns a user "i.e.: john" from its UserGroup. I don't want to delete "john" from the system, but I want to execute a method when it becomes "orphan" of user group (mainly to remove all the permissions "john" has). Is that possible? Something like: _userGroup = relationship("UserGroup", uselist=False, backref=backref("_users", collection_class=set, on_orphan=function_to_remove_permissions() )) Thank you in advance! -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.