Skip to content

Commit

Permalink
request response includes content, no need to return it explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Jan 1, 2012
1 parent 645c453 commit 24e227d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions slumber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,39 @@ def _request(self, method, **kwargs):
elif 500 <= resp.status_code <= 599:
raise exceptions.HttpServerError("Server Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content)

return resp, resp.content
return resp

def get(self, **kwargs):
s = self.get_serializer()

resp, content = self._request("GET", **kwargs)
resp = self._request("GET", **kwargs)
if 200 <= resp.status_code <= 299:
if resp.status_code == 200:
return s.loads(content)
return s.loads(resp.content)
else:
return content
return resp.content
else:
return # @@@ We should probably do some sort of error here? (Is this even possible?)

def post(self, data, **kwargs):
s = self.get_serializer()

resp, content = self._request("POST", body=s.dumps(data), **kwargs)
resp = self._request("POST", body=s.dumps(data), **kwargs)
if 200 <= resp.status_code <= 299:
if resp.status_code == 201:
# @@@ Hacky, see description in __call__
resource_obj = self(url_override=resp.headers["location"])
return resource_obj.get(**kwargs)
else:
return content
return resp.content
else:
# @@@ Need to be Some sort of Error Here or Something
return

def put(self, data, **kwargs):
s = self.get_serializer()

resp, content = self._request("PUT", body=s.dumps(data), **kwargs)
resp = self._request("PUT", body=s.dumps(data), **kwargs)
if 200 <= resp.status_code <= 299:
if resp.status_code == 204:
return True
Expand All @@ -152,7 +152,7 @@ def put(self, data, **kwargs):
return False

def delete(self, **kwargs):
resp, content = self._request("DELETE", **kwargs)
resp = self._request("DELETE", **kwargs)
if 200 <= resp.status_code <= 299:
if resp.status_code == 204:
return True
Expand Down

0 comments on commit 24e227d

Please sign in to comment.