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
efb00e40
Commit
efb00e40
authored
Jul 20, 2014
by
Roman Krejcik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed saving of Pointer to User
parent
ffacfc4b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
parse_rest/datatypes.py
+9
-4
parse_rest/tests.py
+10
-1
parse_rest/user.py
+4
-0
No files found.
parse_rest/datatypes.py
View file @
efb00e40
...
@@ -40,7 +40,7 @@ class ParseType(object):
...
@@ -40,7 +40,7 @@ class ParseType(object):
if
not
is_parse_type
:
if
not
is_parse_type
:
return
parse_data
return
parse_data
native
=
ParseType
.
type_mapping
.
get
(
parse_data
[
'__type'
]
)
native
=
ParseType
.
type_mapping
.
get
(
parse_data
.
pop
(
'__type'
)
)
return
native
.
from_native
(
**
parse_data
)
if
native
else
parse_data
return
native
.
from_native
(
**
parse_data
)
if
native
else
parse_data
@staticmethod
@staticmethod
...
@@ -93,7 +93,7 @@ class Pointer(ParseType):
...
@@ -93,7 +93,7 @@ class Pointer(ParseType):
def
_to_native
(
self
):
def
_to_native
(
self
):
return
{
return
{
'__type'
:
'Pointer'
,
'__type'
:
'Pointer'
,
'className'
:
self
.
_object
.
__class__
.
__name__
,
'className'
:
self
.
_object
.
className
,
'objectId'
:
self
.
_object
.
objectId
'objectId'
:
self
.
_object
.
objectId
}
}
...
@@ -102,7 +102,7 @@ class Pointer(ParseType):
...
@@ -102,7 +102,7 @@ class Pointer(ParseType):
class
EmbeddedObject
(
ParseType
):
class
EmbeddedObject
(
ParseType
):
@classmethod
@classmethod
def
from_native
(
cls
,
**
kw
):
def
from_native
(
cls
,
**
kw
):
klass
=
Object
.
factory
(
kw
.
get
(
'className'
))
klass
=
Object
.
factory
(
kw
.
pop
(
'className'
))
return
klass
(
**
kw
)
return
klass
(
**
kw
)
...
@@ -284,8 +284,13 @@ class ParseResource(ParseBase):
...
@@ -284,8 +284,13 @@ class ParseResource(ParseBase):
if
batch
:
if
batch
:
return
response
,
lambda
response_dict
:
None
return
response
,
lambda
response_dict
:
None
@property
def
className
(
self
):
return
self
.
__class__
.
__name__
_absolute_url
=
property
(
lambda
self
:
'/'
.
join
([
self
.
__class__
.
ENDPOINT_ROOT
,
self
.
objectId
]))
@property
def
_absolute_url
(
self
):
return
'
%
s/
%
s'
%
(
self
.
__class__
.
ENDPOINT_ROOT
,
self
.
objectId
)
createdAt
=
property
(
_get_created_datetime
,
_set_created_datetime
)
createdAt
=
property
(
_get_created_datetime
,
_set_created_datetime
)
updatedAt
=
property
(
_get_updated_datetime
,
_set_updated_datetime
)
updatedAt
=
property
(
_get_updated_datetime
,
_set_updated_datetime
)
...
...
parse_rest/tests.py
View file @
efb00e40
...
@@ -16,7 +16,7 @@ from itertools import chain
...
@@ -16,7 +16,7 @@ from itertools import chain
from
parse_rest.core
import
ResourceRequestNotFound
from
parse_rest.core
import
ResourceRequestNotFound
from
parse_rest.connection
import
register
,
ParseBatcher
from
parse_rest.connection
import
register
,
ParseBatcher
from
parse_rest.datatypes
import
GeoPoint
,
Object
,
Function
from
parse_rest.datatypes
import
GeoPoint
,
Object
,
Function
,
Pointer
from
parse_rest.user
import
User
from
parse_rest.user
import
User
from
parse_rest
import
query
from
parse_rest
import
query
from
parse_rest.installation
import
Push
from
parse_rest.installation
import
Push
...
@@ -170,6 +170,15 @@ class TestObject(unittest.TestCase):
...
@@ -170,6 +170,15 @@ class TestObject(unittest.TestCase):
"batch_delete didn't delete objects"
)
"batch_delete didn't delete objects"
)
class
TestPointer
(
unittest
.
TestCase
):
def
testToNative
(
self
):
ptr
=
Pointer
(
GameScore
(
objectId
=
'xyz'
))
self
.
assertEqual
(
ptr
.
_to_native
(),
dict
(
__type
=
'Pointer'
,
className
=
'GameScore'
,
objectId
=
'xyz'
))
ptr
=
Pointer
(
User
(
objectId
=
'dh56yz'
,
username
=
"dhelmet@spaceballs.com"
))
self
.
assertEqual
(
ptr
.
_to_native
(),
dict
(
__type
=
'Pointer'
,
className
=
'_User'
,
objectId
=
'dh56yz'
))
class
TestTypes
(
unittest
.
TestCase
):
class
TestTypes
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
now
=
datetime
.
datetime
.
now
()
self
.
now
=
datetime
.
datetime
.
now
()
...
...
parse_rest/user.py
View file @
efb00e40
...
@@ -108,6 +108,10 @@ class User(ParseResource):
...
@@ -108,6 +108,10 @@ class User(ParseResource):
return
dict
([(
k
,
ParseType
.
convert_to_parse
(
v
,
as_pointer
=
True
))
return
dict
([(
k
,
ParseType
.
convert_to_parse
(
v
,
as_pointer
=
True
))
for
k
,
v
in
self
.
_editable_attrs
.
items
()])
for
k
,
v
in
self
.
_editable_attrs
.
items
()])
@property
def
className
(
self
):
return
'_User'
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<User:
%
s (Id
%
s)>'
%
(
self
.
username
,
self
.
objectId
)
return
'<User:
%
s (Id
%
s)>'
%
(
self
.
username
,
self
.
objectId
)
...
...
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