@validates... Where have you been? Oh... In the documentation, all along. The day I learn to read, I'll conquer the world
It works great. Thank you! 2011/12/1 Michael Bayer <[email protected]>: > > On Nov 30, 2011, at 7:48 PM, Hector Blanco wrote: > >> Hello everyone! >> >> I am using (yeah, still) SqlAlchemy 0.6.8 and I'm using an >> AttributeExtension to build permissions of users. >> >> >> class UserGroupExtension(AttributeExtension): >> def set(self, state, value, oldvalue, initiator): >> userToUpdate = # !!! do things here to get the user >> value.rebuildPermissions(userToUpdate) >> return value >> >> def remove(self, state, value, initiator): >> removeAllThePermissionForUsersInGroup(value) >> ------------------------------------------------ >> >> So, in the UserGroupExtension, I need to get the user that fired the >> event, to apply the proper permissions to it. >> >> I've tried state.obj(), but that gives me an empty user. > > The "state" object's obj() is the parent User object receiving the events. It > should be the same identity as the User receiving the append. The > @validates decorator will get you the same effect with less boilerplate. > > -- > 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. > > -- 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.
