summaryrefslogtreecommitdiff
path: root/ick2/persistent.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-07-14 16:13:10 +0300
committerLars Wirzenius <liw@liw.fi>2019-08-03 21:06:50 +0300
commit4dd2e14cd15ad2840cfc3636251802f8eb0bc9ba (patch)
treef5fd5b9be0ce316c35ad5876c925e148029474e0 /ick2/persistent.py
parent471b9d6209dc51890c7724b7b57b9121ba30af7d (diff)
downloadick2-4dd2e14cd15ad2840cfc3636251802f8eb0bc9ba.tar.gz
Change: get and use tokens
Diffstat (limited to 'ick2/persistent.py')
-rw-r--r--ick2/persistent.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/ick2/persistent.py b/ick2/persistent.py
index 31473ba..d865207 100644
--- a/ick2/persistent.py
+++ b/ick2/persistent.py
@@ -27,25 +27,25 @@ import ick2
class PersistentStateInterface: # pragma: no cover
- def get_resource_ids(self, kind):
+ def get_resource_ids(self, token, kind):
raise NotImplementedError()
- def has_resource(self, kind, rid):
+ def has_resource(self, token, kind, rid):
raise NotImplementedError()
- def get_resource(self, kind, rid):
+ def get_resource(self, token, kind, rid):
raise NotImplementedError()
- def get_resources(self, kind):
+ def get_resources(self, token, kind):
return [
- self.get_resource(kind, rid)
- for rid in self.get_resource_ids(kind)
+ self.get_resource(token, kind, rid)
+ for rid in self.get_resource_ids(token, kind)
]
- def write_resource(self, kind, rid, resource):
+ def write_resource(self, token, kind, rid, resource):
raise NotImplementedError()
- def remove_resource(self, kind, rid):
+ def remove_resource(self, token, kind, rid):
raise NotImplementedError()
@@ -54,25 +54,25 @@ class MemoryPersistentState(PersistentStateInterface):
def __init__(self):
self._res = {}
- def get_resource_ids(self, kind):
+ def get_resource_ids(self, token, kind):
if kind not in self._res:
return []
return list(self._res[kind].keys())
- def has_resource(self, kind, rid):
+ def has_resource(self, token, kind, rid):
return kind in self._res and rid in self._res[kind]
- def get_resource(self, kind, rid):
+ def get_resource(self, token, kind, rid):
if kind not in self._res or rid not in self._res[kind]:
raise ick2.NotFound(kind=kind, rid=rid)
return self._res[kind][rid]
- def write_resource(self, kind, rid, resource):
+ def write_resource(self, token, kind, rid, resource):
if kind not in self._res:
self._res[kind] = {}
self._res[kind][rid] = resource
- def remove_resource(self, kind, rid):
+ def remove_resource(self, token, kind, rid):
if kind not in self._res or rid not in self._res[kind]:
raise ick2.NotFound(kind=kind, rid=rid)
del self._res[kind][rid]
@@ -83,25 +83,25 @@ class MuckPersistentState(PersistentStateInterface):
def __init__(self):
self._res = {}
- def get_resource_ids(self, kind):
+ def get_resource_ids(self, token, kind):
if kind not in self._res:
return []
return list(self._res[kind].keys())
- def has_resource(self, kind, rid):
+ def has_resource(self, token, kind, rid):
return kind in self._res and rid in self._res[kind]
- def get_resource(self, kind, rid):
+ def get_resource(self, token, kind, rid):
if kind not in self._res or rid not in self._res[kind]:
raise ick2.NotFound(kind=kind, rid=rid)
return self._res[kind][rid]
- def write_resource(self, kind, rid, resource):
+ def write_resource(self, token, kind, rid, resource):
if kind not in self._res:
self._res[kind] = {}
self._res[kind][rid] = resource
- def remove_resource(self, kind, rid):
+ def remove_resource(self, token, kind, rid):
if kind not in self._res or rid not in self._res[kind]:
raise ick2.NotFound(kind=kind, rid=rid)
del self._res[kind][rid]