Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ParsePy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ParsePy
Commits
6e261e83
Commit
6e261e83
authored
Jan 30, 2015
by
David Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #84 from konoufo/master
Solve Datetime object not JSON serializable
parents
251b782d
ba56a569
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
parse_rest/connection.py
+4
-3
No files found.
parse_rest/connection.py
View file @
6e261e83
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment