def handle_put(seq,key, value): """Return a tuple containing True and the message to send back to the client.""" if key not in POROCESSING: POROCESSING.append(key) ds = DataStore(key,value) if ds.put(seq): POROCESSING.remove(key) return (True, 'Key [{}] set to [{}]'.format(key, value)) else: ds.roll_back(seq) POROCESSING.remove(key) return (False, 'Could Not be added')
def handle_delete(seq,key): """Return a tuple containing True if the key could be deleted and the message to send back to the client. use datastore.get and then before doing doing datastore.delete """ ds = DataStore() if ds.get(key): POROCESSING.append(key) if ds.delete(seq,key): POROCESSING.remove(key) return (True,'Done') else: ds.roll_back(seq) POROCESSING.remove(key) return (False,'ERROR: Key [{}] not found and could not be deleted'.format(key))
def handle_abort(seq): ds = DataStore() if ds.roll_back(seq): return (True,'SEQ Aborted') return (False,"Error")