Commit 6e261e83 by David Robinson

Merge pull request #84 from konoufo/master

Solve Datetime object not JSON serializable
parents 251b782d ba56a569
...@@ -44,8 +44,9 @@ def master_key_required(func): ...@@ -44,8 +44,9 @@ def master_key_required(func):
raise core.ParseError(message) raise core.ParseError(message)
func(obj, *args, **kw) func(obj, *args, **kw)
return ret return ret
# Using this as "default=" argument solve the problem with Datetime object not being JSON serializable
def date_handler(obj):
return obj.isoformat() if hasattr(obj, 'isoformat') else obj
class ParseBase(object): class ParseBase(object):
ENDPOINT_ROOT = API_ROOT ENDPOINT_ROOT = API_ROOT
...@@ -72,7 +73,7 @@ class ParseBase(object): ...@@ -72,7 +73,7 @@ class ParseBase(object):
url = uri if uri.startswith(API_ROOT) else cls.ENDPOINT_ROOT + uri url = uri if uri.startswith(API_ROOT) else cls.ENDPOINT_ROOT + uri
if body is None: if body is None:
data = kw and json.dumps(kw) or "{}" data = kw and json.dumps(kw, default=date_handler) or "{}"
else: else:
data = body data = body
if http_verb == 'GET' and data: if http_verb == 'GET' and data:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment