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 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.

Reply via email to