def chained_put(chained, id, value, put=None, overwrite=False, contains=op.contains, **kargs):
stores_with_write = [s for s in chained.stores if s._write]
if len(stores_with_write) == 0:
raise PermissionError('put', chained, 'write')
record = None
putin = []
for store in stores_with_write:
if overwrite or not contains(store, id):
if put:
record = put(store, id, value, **kargs)
else:
record = store.put(id, value, **kargs)
putin.append(store)
if (len(putin) == 0 and
len(stores_with_write) > 0):
raise KeyExistsError(id, chained)
return record
评论列表
文章目录