Mercurial > libervia-backend
changeset 1340:91e72da1d093 frontends_multi_profiles
core (persistent dict): added setdefault method
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Feb 2015 16:54:28 +0100 (2015-02-24) |
parents | 18cd46a264e9 |
children | 6dbeb2ef966c |
files | src/memory/persistent.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/memory/persistent.py Tue Feb 24 16:52:44 2015 +0100 +++ b/src/memory/persistent.py Tue Feb 24 16:54:28 2015 +0100 @@ -118,6 +118,13 @@ def get(self, key, default=None): return self._cache.get(key, default) + def setdefault(self, key, default): + try: + return self._cache[key] + except: + self.__setitem__(key, default) + return default + def force(self, name): """Force saving of an attribute to storage @return: deferred fired when data is actually saved"""