Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
f5754f6d
Commit
f5754f6d
authored
Aug 29, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some rudimentary error checking to forum views
[Hopefully fix #34992235]
parent
30543d45
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
lms/djangoapps/django_comment_client/forum/views.py
+0
-0
lms/lib/comment_client/utils.py
+16
-6
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
f5754f6d
This diff is collapsed.
Click to expand it.
lms/lib/comment_client/utils.py
View file @
f5754f6d
import
requests
import
json
import
json
import
logging
import
requests
import
settings
import
settings
log
=
logging
.
getLogger
(
'mitx.'
+
__name__
)
def
strip_none
(
dic
):
def
strip_none
(
dic
):
return
dict
([(
k
,
v
)
for
k
,
v
in
dic
.
iteritems
()
if
v
is
not
None
])
return
dict
([(
k
,
v
)
for
k
,
v
in
dic
.
iteritems
()
if
v
is
not
None
])
...
@@ -18,15 +21,22 @@ def extract(dic, keys):
...
@@ -18,15 +21,22 @@ def extract(dic, keys):
def
merge_dict
(
dic1
,
dic2
):
def
merge_dict
(
dic1
,
dic2
):
return
dict
(
dic1
.
items
()
+
dic2
.
items
())
return
dict
(
dic1
.
items
()
+
dic2
.
items
())
def
perform_request
(
method
,
url
,
data_or_params
=
None
,
*
args
,
**
kwargs
):
def
perform_request
(
method
,
url
,
data_or_params
=
None
,
*
args
,
**
kwargs
):
if
data_or_params
is
None
:
if
data_or_params
is
None
:
data_or_params
=
{}
data_or_params
=
{}
data_or_params
[
'api_key'
]
=
settings
.
API_KEY
data_or_params
[
'api_key'
]
=
settings
.
API_KEY
if
method
in
[
'post'
,
'put'
,
'patch'
]:
try
:
response
=
requests
.
request
(
method
,
url
,
data
=
data_or_params
)
if
method
in
[
'post'
,
'put'
,
'patch'
]:
else
:
response
=
requests
.
request
(
method
,
url
,
data
=
data_or_params
)
response
=
requests
.
request
(
method
,
url
,
params
=
data_or_params
)
else
:
response
=
requests
.
request
(
method
,
url
,
params
=
data_or_params
)
except
Exception
as
err
:
log
.
exception
(
"Trying to call {method} on {url} with params {params}"
.
format
(
method
=
method
,
url
=
url
,
params
=
data_or_params
))
# Reraise with a single exception type
raise
CommentClientError
(
str
(
err
))
if
200
<
response
.
status_code
<
500
:
if
200
<
response
.
status_code
<
500
:
raise
CommentClientError
(
response
.
text
)
raise
CommentClientError
(
response
.
text
)
elif
response
.
status_code
==
500
:
elif
response
.
status_code
==
500
:
...
...
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