def DELETE(self, api_key, doc_key, level): """Delete the document indicated by the ID.""" global api_keys, TheOneRing if api_key not in api_keys: raise_401() if not len([i for i in TheOneRing.get_nodes()]): raise_500('Service is not operative') try: node = TheOneRing.get_node(doc_key) host, port = node.split('|') target = "/store/%s/%s" % (doc_key, level) ret = do_request(host, port, 'DELETE', target) return ret except Exception as ex: raise_500('%s' % ex)
def PUT(self, api_key, level): global api_keys, TheOneRing if api_key not in api_keys: raise_401() if not len([i for i in TheOneRing.get_nodes()]): raise_500('Service is not operative') try: m = hashlib.md5(self.request.body) doc_key = m.hexdigest() print doc_key node = TheOneRing.get_node(doc_key) host, port = node.split('|') target = "/store/%s/%s" % (doc_key, level) ret = do_request(host, port, 'PUT', target, payload=self.request.body) return ret except Exception as ex: raise_500('%s' % ex)