def delete(self, usernames):
"""Delete L{User}s matching C{username}s.
@param usernames: A sequence of L{User.username}s.
@raise FeatureError: Raised if no L{User.username}s are provided.
@raise UnknownUserError: Raised if one or more usernames don't match
existing L{User}s.
@return: A C{list} of C{(objectID, User.username)} 2-tuples
representing the L{User}s that that were removed.
"""
if isgenerator(usernames):
usernames = list(usernames)
if not usernames:
raise FeatureError('At least one username must be provided.')
usernames = set(usernames)
result = getUsers(usernames=usernames)
existingUsernames = set(result.values(User.username))
unknownUsernames = usernames - existingUsernames
if unknownUsernames:
raise UnknownUserError(list(unknownUsernames))
admin = getUser(u'fluiddb')
deletedUsers = list(result.values(User.objectID, User.username))
# FIXME: Deleting a user will leave the permission exception lists
# containing the user in a corrupt state.
result.remove()
self._factory.tagValues(admin).delete(
[(objectID, systemTag) for objectID, _ in deletedUsers
for systemTag in [u'fluiddb/users/username',
u'fluiddb/users/name',
u'fluiddb/users/email',
u'fluiddb/users/role']])
return deletedUsers
评论列表
文章目录