'Grants or denies permissions to this member.
Args are named parameters with bool or None values (use None to disable
granting or denying the permission). After calling this method,
the relation will be _dirty until _commit is called.'

def update_permissions(self, **kwargs):

    if (not self._permission_class):
        raise NotImplementedError
    perm_set = self._permission_class.loads(self.encoded_permissions)
    if (perm_set is None):
        perm_set = self._permission_class()
    for (k, v) in kwargs.iteritems():
        if (v is None):
            if (k in perm_set):
                del perm_set[k]
        else:
            perm_set[k] = v
    self.encoded_permissions = perm_set.dumps()
