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
c33c782f
Commit
c33c782f
authored
May 29, 2015
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap _invoke_xblock_handler in a bulk_op.
parent
6d7944fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
28 deletions
+35
-28
lms/djangoapps/courseware/module_render.py
+35
-28
No files found.
lms/djangoapps/courseware/module_render.py
View file @
c33c782f
...
...
@@ -908,40 +908,47 @@ def _invoke_xblock_handler(request, course_id, usage_id, handler, suffix):
if
error_msg
:
return
JsonResponse
(
object
=
{
'success'
:
error_msg
},
status
=
413
)
instance
,
tracking_context
=
get_module_by_usage_id
(
request
,
course_id
,
usage_id
)
# Make a CourseKey from the course_id, raising a 404 upon parse error.
try
:
course_key
=
CourseKey
.
from_string
(
course_id
)
except
InvalidKeyError
:
raise
Http404
# Name the transaction so that we can view XBlock handlers separately in
# New Relic. The suffix is necessary for XModule handlers because the
# "handler" in those cases is always just "xmodule_handler".
nr_tx_name
=
"{}.{}"
.
format
(
instance
.
__class__
.
__name__
,
handler
)
nr_tx_name
+=
"/{}"
.
format
(
suffix
)
if
suffix
else
""
newrelic
.
agent
.
set_transaction_name
(
nr_tx_name
,
group
=
"Python/XBlock/Handler"
)
with
modulestore
()
.
bulk_operations
(
course_key
):
instance
,
tracking_context
=
get_module_by_usage_id
(
request
,
course_id
,
usage_id
)
tracking_context_name
=
'module_callback_handler'
req
=
django_to_webob_request
(
request
)
try
:
with
tracker
.
get_tracker
()
.
context
(
tracking_context_name
,
tracking_context
):
resp
=
instance
.
handle
(
handler
,
req
,
suffix
)
# Name the transaction so that we can view XBlock handlers separately in
# New Relic. The suffix is necessary for XModule handlers because the
# "handler" in those cases is always just "xmodule_handler".
nr_tx_name
=
"{}.{}"
.
format
(
instance
.
__class__
.
__name__
,
handler
)
nr_tx_name
+=
"/{}"
.
format
(
suffix
)
if
suffix
else
""
newrelic
.
agent
.
set_transaction_name
(
nr_tx_name
,
group
=
"Python/XBlock/Handler"
)
except
NoSuchHandlerError
:
log
.
exception
(
"XBlock
%
s attempted to access missing handler
%
r"
,
instance
,
handler
)
raise
Http404
tracking_context_name
=
'module_callback_handler'
req
=
django_to_webob_request
(
request
)
try
:
with
tracker
.
get_tracker
()
.
context
(
tracking_context_name
,
tracking_context
):
resp
=
instance
.
handle
(
handler
,
req
,
suffix
)
# If we can't find the module, respond with a 404
except
NotFoundError
:
log
.
exception
(
"Module indicating to user that request doesn't exist"
)
raise
Http404
except
NoSuchHandlerError
:
log
.
exception
(
"XBlock
%
s attempted to access missing handler
%
r"
,
instance
,
handler
)
raise
Http404
# For XModule-specific errors, we log the error and respond with an error message
except
ProcessingError
as
err
:
log
.
warning
(
"Module encountered an error while processing AJAX call"
,
exc_info
=
True
)
return
JsonResponse
(
object
=
{
'success'
:
err
.
args
[
0
]},
status
=
200
)
# If we can't find the module, respond with a 404
except
NotFoundError
:
log
.
exception
(
"Module indicating to user that request doesn't exist"
)
raise
Http404
# If any other error occurred, re-raise it to trigger a 500 response
except
Exception
:
log
.
exception
(
"error executing xblock handler"
)
raise
# For XModule-specific errors, we log the error and respond with an error message
except
ProcessingError
as
err
:
log
.
warning
(
"Module encountered an error while processing AJAX call"
,
exc_info
=
True
)
return
JsonResponse
(
object
=
{
'success'
:
err
.
args
[
0
]},
status
=
200
)
# If any other error occurred, re-raise it to trigger a 500 response
except
Exception
:
log
.
exception
(
"error executing xblock handler"
)
raise
return
webob_to_django_response
(
resp
)
...
...
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