annotate sat/memory/persistent.py @ 3136:9d0df638c8b4

dates update
author Goffi <goffi@goffi.org>
date Wed, 29 Jan 2020 09:50:54 +0100
parents ab2696e34d29
children 559a625a236b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
1 #!/usr/bin/env python3
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
4 # SAT: a jabber client
3136
9d0df638c8b4 dates update
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
5 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
10 # (at your option) any later version.
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
15 # GNU Affero General Public License for more details.
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 592
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 609
diff changeset
20 from sat.core.i18n import _
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 979
diff changeset
21 from sat.core.log import getLogger
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 979
diff changeset
22 log = getLogger(__name__)
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
23 from twisted.python import failure
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
24
592
e5a875a3311b Fix pep8 support in src/memory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
25
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
26 class MemoryNotInitializedError(Exception):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
27 pass
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
28
592
e5a875a3311b Fix pep8 support in src/memory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
29
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
30 class PersistentDict(object):
592
e5a875a3311b Fix pep8 support in src/memory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
31 r"""A dictionary which save persistently each value assigned
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
32
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
33 /!\ be careful, each assignment means a database write
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
34 /!\ Memory must be initialised before loading/setting value with instances of this class"""
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
35 storage = None
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
36 binary = False
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
37
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
38 def __init__(self, namespace, profile=None):
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
39 """
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
40
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
41 @param namespace: unique namespace for this dictionary
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
42 @param profile(unicode, None): profile which *MUST* exists, or None for general values
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
43 """
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
44 if not self.storage:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 979
diff changeset
45 log.error(_("PersistentDict can't be used before memory initialisation"))
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
46 raise MemoryNotInitializedError
2890
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
47 self._cache = {}
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.namespace = namespace
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
49 self.profile = profile
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
50
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
51 def _setCache(self, data):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
52 self._cache = data
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
53
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
54 def load(self):
1029
f6182f6418ea memory: add class ProfileSessions based on Sessions
souliane <souliane@mailoo.org>
parents: 993
diff changeset
55 """Load persistent data from storage.
f6182f6418ea memory: add class ProfileSessions based on Sessions
souliane <souliane@mailoo.org>
parents: 993
diff changeset
56
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
57 need to be called before any other operation
1029
f6182f6418ea memory: add class ProfileSessions based on Sessions
souliane <souliane@mailoo.org>
parents: 993
diff changeset
58 @return: defers the PersistentDict instance itself
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
59 """
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
60 d = self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile)
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
61 d.addCallback(self._setCache)
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2734
diff changeset
62 d.addCallback(lambda __: self)
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
63 return d
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
64
1292
b29a065a66f0 core: added items() and iteritems() methods to PersistentDict
Goffi <goffi@goffi.org>
parents: 1029
diff changeset
65 def iteritems(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
66 return iter(self._cache.items())
1292
b29a065a66f0 core: added items() and iteritems() methods to PersistentDict
Goffi <goffi@goffi.org>
parents: 1029
diff changeset
67
b29a065a66f0 core: added items() and iteritems() methods to PersistentDict
Goffi <goffi@goffi.org>
parents: 1029
diff changeset
68 def items(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
69 return list(self._cache.items())
1292
b29a065a66f0 core: added items() and iteritems() methods to PersistentDict
Goffi <goffi@goffi.org>
parents: 1029
diff changeset
70
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def __repr__(self):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
72 return self._cache.__repr__()
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
73
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
74 def __str__(self):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
75 return self._cache.__str__()
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
76
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
77 def __lt__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
78 return self._cache.__lt__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
79
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
80 def __le__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
81 return self._cache.__le__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
82
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
83 def __eq__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
84 return self._cache.__eq__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
85
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def __ne__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
87 return self._cache.__ne__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
88
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
89 def __gt__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
90 return self._cache.__gt__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
91
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
92 def __ge__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
93 return self._cache.__ge__(other)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
94
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
95 def __cmp__(self, other):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
96 return self._cache.__cmp__(other)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
97
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
98 def __hash__(self):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
99 return self._cache.__hash__()
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
100
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
101 def __bool__(self):
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
102 return self._cache.__len__() != 0
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
103
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
104 def __contains__(self, key):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
105 return self._cache.__contains__(key)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
106
979
8f8bdd31375a core (memory): added __iter__ to PersistentDict
Goffi <goffi@goffi.org>
parents: 811
diff changeset
107 def __iter__(self):
8f8bdd31375a core (memory): added __iter__ to PersistentDict
Goffi <goffi@goffi.org>
parents: 811
diff changeset
108 return self._cache.__iter__()
8f8bdd31375a core (memory): added __iter__ to PersistentDict
Goffi <goffi@goffi.org>
parents: 811
diff changeset
109
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
110 def __getitem__(self, key):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
111 return self._cache.__getitem__(key)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
112
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
113 def __setitem__(self, key, value):
2890
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
114 self.storage.setPrivateValue(self.namespace, key, value, self.binary,
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
115 self.profile)
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
116 return self._cache.__setitem__(key, value)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
117
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
118 def __delitem__(self, key):
2302
f824b6026b73 core (memory/persistent): fixed calls to delPrivateValue
Goffi <goffi@goffi.org>
parents: 2209
diff changeset
119 self.storage.delPrivateValue(self.namespace, key, self.binary, self.profile)
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
120 return self._cache.__delitem__(key)
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
121
2890
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
122 def clear(self):
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
123 """Delete all values from this namespace"""
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
124 self._cache.clear()
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
125 return self.storage.delPrivateNamespace(self.namespace, self.binary, self.profile)
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
126
442
ab9ddf6c7eaf core: added get method to PersistentDictionary
Goffi <goffi@goffi.org>
parents: 439
diff changeset
127 def get(self, key, default=None):
ab9ddf6c7eaf core: added get method to PersistentDictionary
Goffi <goffi@goffi.org>
parents: 439
diff changeset
128 return self._cache.get(key, default)
ab9ddf6c7eaf core: added get method to PersistentDictionary
Goffi <goffi@goffi.org>
parents: 439
diff changeset
129
1340
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
130 def setdefault(self, key, default):
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
131 try:
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
132 return self._cache[key]
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
133 except:
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
134 self.__setitem__(key, default)
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
135 return default
91e72da1d093 core (persistent dict): added setdefault method
Goffi <goffi@goffi.org>
parents: 1292
diff changeset
136
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def force(self, name):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
138 """Force saving of an attribute to storage
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
139
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
140 @return: deferred fired when data is actually saved
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
141 """
2890
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
142 return self.storage.setPrivateValue(self.namespace, name, self._cache[name],
c652d079a9a1 core (memory/persistent): added clear method + initialise with a dict:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
143 self.binary, self.profile)
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
144
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
145
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
146 class PersistentBinaryDict(PersistentDict):
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
147 """Persistent dict where value can be any python data (instead of string only)"""
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
148 binary = True
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
149
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
150
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
151 class LazyPersistentBinaryDict(PersistentBinaryDict):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
152 r"""PersistentBinaryDict which get key/value when needed
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
153
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
154 This Persistent need more database access, it is suitable for largest data,
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
155 to save memory.
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
156 /!\ most of methods return a Deferred
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
157 """
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
158 # TODO: missing methods should be implemented using database access
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
159 # TODO: a cache would be useful (which is deleted after a timeout)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
160
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
161 def load(self):
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
162 # we show a warning as calling load on LazyPersistentBinaryDict sounds like a code mistake
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
163 log.warning(_("Calling load on LazyPersistentBinaryDict while it's not needed"))
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
164
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
165 def iteritems(self):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
166 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
167
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
168 def items(self):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
169 return self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile)
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
170
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
171 def __repr__(self):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
172 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
173
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
174 def __str__(self):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
175 return "LazyPersistentBinaryDict (namespace: {})".format(self.namespace)
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
176
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
177 def __lt__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
178 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
179
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
180 def __le__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
181 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
183 def __eq__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
184 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
185
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
186 def __ne__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
187 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
188
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
189 def __gt__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
190 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
191
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
192 def __ge__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
193 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
194
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
195 def __cmp__(self, other):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
196 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
197
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
198 def __hash__(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
199 return hash(str(self.__class__) + self.namespace + (self.profile or ''))
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
200
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2890
diff changeset
201 def __bool__(self):
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
202 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
203
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
204 def __contains__(self, key):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
205 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
206
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
207 def __iter__(self):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
208 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
209
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
210 def _data2value(self, data, key):
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
211 try:
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
212 return data[key]
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
213 except KeyError as e:
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
214 # we return a Failure here to avoid the jump
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
215 # into debugger in debug mode.
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
216 raise failure.Failure(e)
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
217
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
218 def __getitem__(self, key):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
219 """get the value as a Deferred"""
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
220 d = self.storage.getPrivates(self.namespace, keys=[key], binary=self.binary,
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
221 profile=self.profile)
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
222 d.addCallback(self._data2value, key)
2209
ea41cf1e6d29 memory (persistent, sqlite): fixed getPrivates bug with keys arguments and its use in LazyPersistentBinaryDict
Goffi <goffi@goffi.org>
parents: 2182
diff changeset
223 return d
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
224
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
225 def __setitem__(self, key, value):
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
226 self.storage.setPrivateValue(self.namespace, key, value, self.binary,
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
227 self.profile)
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
228
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
229 def __delitem__(self, key):
2302
f824b6026b73 core (memory/persistent): fixed calls to delPrivateValue
Goffi <goffi@goffi.org>
parents: 2209
diff changeset
230 self.storage.delPrivateValue(self.namespace, key, self.binary, self.profile)
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
231
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
232 def _defaultOrException(self, failure_, default):
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
233 failure_.trap(KeyError)
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
234 return default
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
235
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
236 def get(self, key, default=None):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
237 d = self.__getitem__(key)
2644
e107089d6640 core (memory/persistent): better default value handling in LazyPersistentBinaryDict (don't jump to debugger in debug mode if value is not found)
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
238 d.addErrback(self._defaultOrException, default=default)
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
239 return d
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
240
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
241 def setdefault(self, key, default):
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
242 raise NotImplementedError
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
243
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
244 def force(self, name, value):
432
31e8c48b5f5d core: - memory refactoring (moved memory.py and sqlite.py from tools to memory)
Goffi <goffi@goffi.org>
parents:
diff changeset
245 """Force saving of an attribute to storage
2182
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
246
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
247 @param value(object): value is needed for LazyPersistentBinaryDict
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
248 @return: deferred fired when data is actually saved
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
249 """
087eec4c6c07 memory (persistent, sqlite): better private values handling + new LazyPersistentBinaryDict:
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
250 return self.storage.setPrivateValue(self.namespace, name, value, self.binary, self.profile)
2734
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
251
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
252 def remove(self, key):
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
253 """Delete a key from sotrage, and return a deferred called when it's done
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
254
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
255 @param key(unicode): key to delete
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
256 @return (D): A deferred fired when delete is done
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
257 """
9702025f6dff core (memory/persistent): new LazyPersistentBinaryDict.remove method
Goffi <goffi@goffi.org>
parents: 2644
diff changeset
258 return self.storage.delPrivateValue(self.namespace, key, self.binary, self.profile)