def set(self, name, value): """Set a single setting. :param name: Setting name :param value: Setting value; must be JSON-serializable """ self._check_name(name) Setting.set(self.module, name, self._convert_from_python(name, value)) self._flush_cache()
def set(self, name, value): """Sets a single setting. :param name: Setting name :param value: Setting value; must be JSON-serializable """ self._check_name(name) Setting.set(self.module, name, self._convert_from_python(name, value)) self._flush_cache()
def test_set_enum(): class Useless(int, Enum): thing = 1337 Setting.set_multi('foo', {'foo': Useless.thing}) Setting.set('foo', 'bar', Useless.thing) for key in {'foo', 'bar'}: value = Setting.get('foo', key) assert value == Useless.thing assert value == Useless.thing.value assert not isinstance(value, Useless) # we store it as a plain value!
def delete(self, *names): """Delete settings. :param names: One or more names of settings to delete """ self._split_call( names, lambda name: Setting.delete(self.module, *name), lambda name: SettingPrincipal.delete(self.module, *name)) self._flush_cache()
def delete(self, *names): """Deletes settings. :param names: One or more names of settings to delete """ self._split_call(names, lambda name: Setting.delete(self.module, *name), lambda name: SettingPrincipal.delete(self.module, *name)) self._flush_cache()
def set_multi(self, items): """Sets multiple settings at once. :param items: Dict containing the new settings """ self._split_call(items, lambda x: Setting.set_multi(self.module, x), lambda x: SettingPrincipal.set_acl_multi(self.module, x)) self._flush_cache()
def set_multi(self, items): """Sets multiple settings at once. :param items: Dict containing the new settings """ self._split_call( items, lambda x: Setting.set_multi(self.module, x), lambda x: SettingPrincipal.set_acl_multi(self.module, x)) self._flush_cache()
def set_multi(self, items): """Set multiple settings at once. :param items: Dict containing the new settings """ items = {k: self._convert_from_python(k, v) for k, v in items.items()} self._split_call( items, lambda x: Setting.set_multi(self.module, x), lambda x: SettingPrincipal.set_acl_multi(self.module, x)) self._flush_cache()
def set_multi(self, items): """Sets multiple settings at once. :param items: Dict containing the new settings """ items = {k: self._convert_from_python(k, v) for k, v in items.iteritems()} self._split_call(items, lambda x: Setting.set_multi(self.module, x), lambda x: SettingPrincipal.set_acl_multi(self.module, x)) self._flush_cache()
def delete_all(self): """Delete all settings.""" Setting.delete_all(self.module) SettingPrincipal.delete_all(self.module) self._flush_cache()
def delete_all(self): """Deletes all settings.""" Setting.delete_all(self.module) SettingPrincipal.delete_all(self.module) self._flush_cache()