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
af90f847
Commit
af90f847
authored
Jul 31, 2013
by
Williams Mendez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python3 support
parent
2001c5ec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
parse_rest/connection.py
+13
-6
parse_rest/query.py
+4
-0
parse_rest/tests.py
+9
-3
No files found.
parse_rest/connection.py
View file @
af90f847
...
...
@@ -11,8 +11,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
urllib2
import
urllib
try
:
from
urllib2
import
Request
,
urlopen
,
HTTPError
from
urllib
import
urlencode
except
ImportError
:
# is Python3
from
urllib.request
import
Request
,
urlopen
from
urllib.error
import
HTTPError
from
urllib.parse
import
urlencode
import
json
import
core
...
...
@@ -70,10 +77,10 @@ class ParseBase(object):
url
=
uri
if
uri
.
startswith
(
API_ROOT
)
else
cls
.
ENDPOINT_ROOT
+
uri
data
=
kw
and
json
.
dumps
(
kw
)
or
"{}"
if
http_verb
==
'GET'
and
data
:
url
+=
'?
%
s'
%
url
lib
.
url
encode
(
kw
)
url
+=
'?
%
s'
%
urlencode
(
kw
)
data
=
None
request
=
urllib2
.
Request
(
url
,
data
,
headers
)
request
=
Request
(
url
,
data
,
headers
)
request
.
add_header
(
'Content-type'
,
'application/json'
)
request
.
add_header
(
'X-Parse-Application-Id'
,
app_id
)
request
.
add_header
(
'X-Parse-REST-API-Key'
,
rest_key
)
...
...
@@ -84,8 +91,8 @@ class ParseBase(object):
request
.
get_method
=
lambda
:
http_verb
try
:
response
=
url
lib2
.
url
open
(
request
)
except
urllib2
.
HTTPError
,
e
:
response
=
urlopen
(
request
)
except
HTTPError
as
e
:
exc
=
{
400
:
core
.
ResourceRequestBadRequest
,
401
:
core
.
ResourceRequestLoginRequired
,
...
...
parse_rest/query.py
View file @
af90f847
...
...
@@ -15,6 +15,10 @@ import json
import
collections
import
copy
try
:
unicode
=
unicode
except
NameError
:
unicode
=
str
class
QueryResourceDoesNotExist
(
Exception
):
'''Query returned no results'''
...
...
parse_rest/tests.py
View file @
af90f847
...
...
@@ -24,6 +24,12 @@ except ImportError:
sys
.
exit
(
'You must create a settings_local.py file with APPLICATION_ID, '
\
'REST_API_KEY, MASTER_KEY variables set'
)
try
:
unicode
=
unicode
except
NameError
:
# is python3
unicode
=
str
register
(
getattr
(
settings_local
,
'APPLICATION_ID'
),
getattr
(
settings_local
,
'REST_API_KEY'
),
...
...
@@ -318,9 +324,9 @@ class TestFunction(unittest.TestCase):
settings_local
.
MASTER_KEY
))
try
:
subprocess
.
call
([
"parse"
,
"deploy"
])
except
OSError
,
why
:
print
"parse command line tool must be installed "
\
"(see https://www.parse.com/docs/cloud_code_guide)"
except
OSError
as
why
:
print
(
"parse command line tool must be installed "
\
"(see https://www.parse.com/docs/cloud_code_guide)"
)
self
.
skipTest
(
why
)
os
.
chdir
(
original_dir
)
...
...
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