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
250d3694
Commit
250d3694
authored
Feb 03, 2013
by
David Robinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 compliance changes
parent
2b5a26b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
parse_rest/__init__.py
+10
-6
parse_rest/query.py
+6
-3
parse_rest/user.py
+4
-2
No files found.
parse_rest/__init__.py
View file @
250d3694
...
@@ -35,7 +35,8 @@ class ParseType(object):
...
@@ -35,7 +35,8 @@ class ParseType(object):
@staticmethod
@staticmethod
def
convert
(
parse_data
):
def
convert
(
parse_data
):
is_parse_type
=
isinstance
(
parse_data
,
dict
)
and
'__type'
in
parse_data
is_parse_type
=
isinstance
(
parse_data
,
dict
)
and
'__type'
in
parse_data
if
not
is_parse_type
:
return
parse_data
if
not
is_parse_type
:
return
parse_data
parse_type
=
parse_data
[
'__type'
]
parse_type
=
parse_data
[
'__type'
]
native
=
{
native
=
{
...
@@ -211,7 +212,8 @@ class ParseResource(ParseBase):
...
@@ -211,7 +212,8 @@ class ParseResource(ParseBase):
return
cls
(
**
cls
.
GET
(
'/'
+
resource_id
))
return
cls
(
**
cls
.
GET
(
'/'
+
resource_id
))
def
__init__
(
self
,
**
kw
):
def
__init__
(
self
,
**
kw
):
for
key
,
value
in
kw
.
items
():
setattr
(
self
,
key
,
value
)
for
key
,
value
in
kw
.
items
():
setattr
(
self
,
key
,
value
)
def
_to_native
(
self
):
def
_to_native
(
self
):
# serializes all attributes that need to be persisted on Parse
# serializes all attributes that need to be persisted on Parse
...
@@ -228,7 +230,7 @@ class ParseResource(ParseBase):
...
@@ -228,7 +230,7 @@ class ParseResource(ParseBase):
def
_set_object_id
(
self
,
value
):
def
_set_object_id
(
self
,
value
):
if
hasattr
(
self
,
'_object_id'
):
if
hasattr
(
self
,
'_object_id'
):
raise
ValueError
,
'Can not re-set object id'
raise
ValueError
(
'Can not re-set object id'
)
self
.
_object_id
=
value
self
.
_object_id
=
value
def
_get_updated_datetime
(
self
):
def
_get_updated_datetime
(
self
):
...
@@ -263,7 +265,7 @@ class ParseResource(ParseBase):
...
@@ -263,7 +265,7 @@ class ParseResource(ParseBase):
def
_update
(
self
):
def
_update
(
self
):
# URL: /1/classes/<className>/<objectId>
# URL: /1/classes/<className>/<objectId>
# HTTP Verb: PUT
# HTTP Verb: PUT
response
=
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
self
.
_to_native
())
response
=
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
self
.
_to_native
())
self
.
updatedAt
=
response
[
'updatedAt'
]
self
.
updatedAt
=
response
[
'updatedAt'
]
...
@@ -286,7 +288,8 @@ class Object(ParseResource):
...
@@ -286,7 +288,8 @@ class Object(ParseResource):
@classmethod
@classmethod
def
factory
(
cls
,
class_name
):
def
factory
(
cls
,
class_name
):
class
DerivedClass
(
cls
):
pass
class
DerivedClass
(
cls
):
pass
DerivedClass
.
__name__
=
class_name
DerivedClass
.
__name__
=
class_name
return
DerivedClass
return
DerivedClass
...
@@ -306,7 +309,8 @@ class Object(ParseResource):
...
@@ -306,7 +309,8 @@ class Object(ParseResource):
@property
@property
def
_absolute_url
(
self
):
def
_absolute_url
(
self
):
if
not
self
.
objectId
:
return
None
if
not
self
.
objectId
:
return
None
return
'/'
.
join
([
self
.
__class__
.
ENDPOINT_ROOT
,
self
.
objectId
])
return
'/'
.
join
([
self
.
__class__
.
ENDPOINT_ROOT
,
self
.
objectId
])
...
...
parse_rest/query.py
View file @
250d3694
...
@@ -54,7 +54,8 @@ class Queryset(object):
...
@@ -54,7 +54,8 @@ class Queryset(object):
yield
self
.
_results
.
pop
(
0
)
yield
self
.
_results
.
pop
(
0
)
def
where
(
self
,
**
kw
):
def
where
(
self
,
**
kw
):
for
key
,
value
in
kw
.
items
():
self
.
eq
(
key
,
value
)
for
key
,
value
in
kw
.
items
():
self
.
eq
(
key
,
value
)
return
self
return
self
def
eq
(
self
,
name
,
value
):
def
eq
(
self
,
name
,
value
):
...
@@ -102,8 +103,10 @@ class Queryset(object):
...
@@ -102,8 +103,10 @@ class Queryset(object):
def
get
(
self
):
def
get
(
self
):
results
=
self
.
_fetch
()
results
=
self
.
_fetch
()
if
len
(
results
)
==
0
:
raise
QueryResourceDoesNotExist
if
len
(
results
)
==
0
:
if
len
(
results
)
>=
2
:
raise
QueryResourceMultipleResultsReturned
raise
QueryResourceDoesNotExist
if
len
(
results
)
>=
2
:
raise
QueryResourceMultipleResultsReturned
return
results
[
0
]
return
results
[
0
]
def
_fetch
(
self
):
def
_fetch
(
self
):
...
...
parse_rest/user.py
View file @
250d3694
...
@@ -56,12 +56,14 @@ class User(ParseResource):
...
@@ -56,12 +56,14 @@ class User(ParseResource):
@staticmethod
@staticmethod
def
signup
(
username
,
password
,
**
kw
):
def
signup
(
username
,
password
,
**
kw
):
return
User
(
**
User
.
POST
(
''
,
username
=
username
,
password
=
password
,
**
kw
))
return
User
(
**
User
.
POST
(
''
,
username
=
username
,
password
=
password
,
**
kw
))
@staticmethod
@staticmethod
def
login
(
username
,
password
):
def
login
(
username
,
password
):
login_url
=
'/'
.
join
([
API_ROOT
,
'login'
])
login_url
=
'/'
.
join
([
API_ROOT
,
'login'
])
return
User
(
**
User
.
GET
(
login_url
,
username
=
username
,
password
=
password
))
return
User
(
**
User
.
GET
(
login_url
,
username
=
username
,
password
=
password
))
@staticmethod
@staticmethod
def
request_password_reset
(
email
):
def
request_password_reset
(
email
):
...
...
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