Repository,remote: Rename argument of get to 'id'.

This commit is contained in:
Martin Hostettler 2016-11-10 11:08:45 +01:00
parent 8955d8bb2a
commit 1edff44b3d
2 changed files with 13 additions and 13 deletions

View file

@ -88,7 +88,7 @@ compatMap = {
'__len__': (),
'list': ('limit', 'marker', ),
'put': ('id', 'data', ),
'get': ('id_', ),
'get': ('id', ),
'delete': ('id', ),
'save_key': ('keydata', ),
'load_key': (),
@ -690,12 +690,12 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
if calls:
if is_preloaded:
assert cmd == 'get', "is_preload is only supported for 'get'"
if calls[0]['id_'] in self.chunkid_to_msgids:
waiting_for.append(pop_preload_msgid(calls.pop(0)['id_']))
if calls[0]['id'] in self.chunkid_to_msgids:
waiting_for.append(pop_preload_msgid(calls.pop(0)['id']))
else:
args = calls.pop(0)
if cmd == 'get' and args['id_'] in self.chunkid_to_msgids:
waiting_for.append(pop_preload_msgid(args['id_']))
if cmd == 'get' and args['id'] in self.chunkid_to_msgids:
waiting_for.append(pop_preload_msgid(args['id']))
else:
self.msgid += 1
waiting_for.append(self.msgid)
@ -705,7 +705,7 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
self.to_send = msgpack.packb((1, self.msgid, cmd, self.named_to_positional(cmd, args)))
if not self.to_send and self.preload_ids:
chunk_id = self.preload_ids.pop(0)
args = {'id_': chunk_id}
args = {'id': chunk_id}
self.msgid += 1
self.chunkid_to_msgids.setdefault(chunk_id, []).append(self.msgid)
if self.dictFormat:
@ -756,12 +756,12 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
def scan(self, limit=None, marker=None):
"""actual remoting is done via self.call in the @api decorator"""
def get(self, id_):
for resp in self.get_many([id_]):
def get(self, id):
for resp in self.get_many([id]):
return resp
def get_many(self, ids, is_preloaded=False):
for resp in self.call_many('get', [{'id_': id_} for id_ in ids], is_preloaded=is_preloaded):
for resp in self.call_many('get', [{'id': id} for id in ids], is_preloaded=is_preloaded):
yield resp
@api(since=parse_version('1.0.0'))

View file

@ -825,14 +825,14 @@ class Repository:
return result
return result
def get(self, id_):
def get(self, id):
if not self.index:
self.index = self.open_index(self.get_transaction_id())
try:
segment, offset = self.index[id_]
return self.io.read(segment, offset, id_)
segment, offset = self.index[id]
return self.io.read(segment, offset, id)
except KeyError:
raise self.ObjectNotFound(id_, self.path) from None
raise self.ObjectNotFound(id, self.path) from None
def get_many(self, ids, is_preloaded=False):
for id_ in ids: