def service_addUser(self, context, username, method, password, groups): username = getUsername(username) password = getPassword(password) groups = getList(getGroup, groups) #method is checked in auth_basemethods.AbstractAuth.hash_password if self.auth.addUser(username, method, password, groups): self.info(context, "User %s added" % username) yield self.modified() returnValue(True) returnValue(False)
def getAddressList(attr, key, address_type): default = (None,) if key not in attr: return default addresses = [] for value in getList(getUnicode, attr.pop(key)): ips = getIP(value, address_type) addresses.extend(ips) if not addresses: return default return addresses
def service_editUser(self, context, username, method, password, groups): """ Edit a user account. password is optional """ username = getUsername(username) password = getPassword(password, False) groups = getList(getGroup, groups) #method is checked in auth_basemethods.AbstractAuth.hash_password if self.auth.editUser(username, method, password, groups): self.info(context, "User %s modified" % username) yield self.modified() returnValue(True) returnValue(False)
def service_groupCreate(self, context, id, library, objects): """ Create a new group of objects: - id : unicode string of the group identifier - library : name of the library that stores this group ("applications", "protocols" ...) - objects: list of object identifiers contained in the group """ id = getUnicode(id) objects = getList(getUnicode, objects) library = self.getRuleset(context).getLibrary(library) attr = {'id': id, 'objects': objects} updates = library.createGroup(attr) self.saveSession(context) return updates
def getIntegerList(value): return getList(getInteger, value)