Permalink
Browse files

Updated to use new iron_core auto-parsing of JSON. Fixed bug in decre…

…ment.
  • Loading branch information...
1 parent ec1955e commit 8359199e1237c06e7f64e10291ca7eaf8d20e6ff @paddycarver paddycarver committed May 22, 2012
Showing with 4 additions and 7 deletions.
  1. +4 −7 iron_cache.py
View
@@ -74,8 +74,7 @@ def caches(self, options={}):
if query != "":
url = "%s?%s" % (url, query)
result = self.client.get(url)
- result = json.loads(result["body"])
- return [cache["name"] for cache in result]
+ return [cache["name"] for cache in result["body"]]
def get(self, key, cache=None):
"""Query the server for an item, parse the JSON, and return the result.
@@ -94,8 +93,7 @@ def get(self, key, cache=None):
key = urllib.quote_plus(key)
url = "caches/%s/items/%s" % (cache, key)
result = self.client.get(url)
- result = json.loads(result["body"])
- return Item(values=result)
+ return Item(values=result["body"])
def put(self, key, value, cache=None, options={}):
"""Query the server to set the key specified to the value specified in
@@ -172,7 +170,7 @@ def increment(self, key, cache=None, amount=1):
result = self.client.post("caches/%s/items/%s/increment" % (cache,
key), body, {"Content-Type": "application/json"})
- result = json.loads(result["body"])
+ result = result["body"]
return Item(values=result, cache=cache, key=key)
def decrement(self, key, cache=None, amount=1):
@@ -187,5 +185,4 @@ def decrement(self, key, cache=None, amount=1):
"""
amount = amount * -1
- return self.increment(key=key, cache=cache, amount=amount,
- options=options)
+ return self.increment(key=key, cache=cache, amount=amount)

0 comments on commit 8359199

Please sign in to comment.