def grantPermissionToRole(self, permission_id, role_id): """Bind the permission to the role. """ s = select( [rpm.c.permission_id ], and_( rpm.c.object_id == self.oid, rpm.c.permission_id == permission_id, rpm.c.role_id == role_id, rpm.c.object_type == self.object_type ) ) if s.execute().fetchone(): self.unsetPermissionFromRole( permission_id, role_id ) rpm.insert( values = dict( permission_id = permission_id, role_id = role_id, object_id = self.oid, object_type = self.object_type ) ).execute()