def do_PUT(self, request): service = request.groups[0] if service == "claim": try: claim = int(request.data) self.context.update_claim(claim) return tc.succeed(ts.Response(200)) except ValueError: return tc.succeed(ts.Response(400)) elif service == "balance": self.context.balance() return tc.succeed(ts.Response(200)) return tc.succeed(ts.Response(404))
def do_PUT(self, request): kvlist = pickle.loads(bz2.decompress(request.data)) if not kvlist: return tc.succeed(ts.Response(200, None, None)) d = self.context.local_multi_put(kvlist) d.add_both(self._put_complete) return d
def _respond_get_ok(self): if self.response.called: return resolved = vectorclock.resolve_list( [result for replica, result in self.results]) vc, value = resolved context = self._vc_to_context(vc) code = 200 if isinstance(value, list): code = 300 self.response.callback( ts.Response(code, {"X-VinzClortho-Context": context}, value))
def do_GET(self, request): service = request.groups[0] if service == "claim": return tc.succeed( ts.Response(200, None, str(self.context.get_claim()))) return tc.succeed(ts.Response(404))
def _put_complete(self, result): return ts.Response(200, None, None)
def do_PUT(self, request): log.info("Metadata submitted by %s", request.client_address) self.context.update_meta(pickle.loads(bz2.decompress(request.data))) return tc.succeed(ts.Response(200, None, None))
def do_GET(self, request): log.info("Metadata requested by %s", request.client_address) return tc.succeed( ts.Response(200, None, bz2.compress(pickle.dumps(self.context._metadata))))
def _respond_ok(self): self.response.callback(ts.Response(200))
def _respond_error(self): if self.response.called: return self.response.callback(ts.Response(404))
def _error(self, result): return ts.Response(404)
def _ok(self, result): return ts.Response(200)
def _ok_get(self, result): return ts.Response(200, None, result)