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
dc491c4c
Commit
dc491c4c
authored
Feb 27, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7156 from edx/clintonb/cs-celery-serialize-fix
Fixed Celery Serialization Bug
parents
d42adcf4
4062b94a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
lms/djangoapps/course_structure_api/v0/tests.py
+1
-1
lms/djangoapps/course_structure_api/v0/views.py
+1
-1
openedx/core/djangoapps/content/course_structures/management/commands/generate_course_structure.py
+1
-1
openedx/core/djangoapps/content/course_structures/models.py
+8
-5
No files found.
lms/djangoapps/course_structure_api/v0/tests.py
View file @
dc491c4c
...
@@ -302,7 +302,7 @@ class CourseStructureTests(CourseDetailMixin, CourseViewTestsMixin, ModuleStoreT
...
@@ -302,7 +302,7 @@ class CourseStructureTests(CourseDetailMixin, CourseViewTestsMixin, ModuleStoreT
super
(
CourseStructureTests
,
self
)
.
setUp
()
super
(
CourseStructureTests
,
self
)
.
setUp
()
# Ensure course structure exists for the course
# Ensure course structure exists for the course
update_course_structure
(
self
.
course
.
id
)
update_course_structure
(
unicode
(
self
.
course
.
id
)
)
def
test_get
(
self
):
def
test_get
(
self
):
"""
"""
...
...
lms/djangoapps/course_structure_api/v0/views.py
View file @
dc491c4c
...
@@ -191,7 +191,7 @@ class CourseStructure(CourseViewMixin, RetrieveAPIView):
...
@@ -191,7 +191,7 @@ class CourseStructure(CourseViewMixin, RetrieveAPIView):
return
super
(
CourseStructure
,
self
)
.
retrieve
(
request
,
*
args
,
**
kwargs
)
return
super
(
CourseStructure
,
self
)
.
retrieve
(
request
,
*
args
,
**
kwargs
)
except
models
.
CourseStructure
.
DoesNotExist
:
except
models
.
CourseStructure
.
DoesNotExist
:
# If we don't have data stored, generate it and return a 503.
# If we don't have data stored, generate it and return a 503.
models
.
update_course_structure
.
delay
(
self
.
course
.
id
)
models
.
update_course_structure
.
delay
(
unicode
(
self
.
course
.
id
)
)
return
Response
(
status
=
503
,
headers
=
{
'Retry-After'
:
'120'
})
return
Response
(
status
=
503
,
headers
=
{
'Retry-After'
:
'120'
})
def
get_object
(
self
,
queryset
=
None
):
def
get_object
(
self
,
queryset
=
None
):
...
...
openedx/core/djangoapps/content/course_structures/management/commands/generate_course_structure.py
View file @
dc491c4c
...
@@ -39,7 +39,7 @@ class Command(BaseCommand):
...
@@ -39,7 +39,7 @@ class Command(BaseCommand):
for
course_key
in
course_keys
:
for
course_key
in
course_keys
:
try
:
try
:
update_course_structure
(
course_key
)
update_course_structure
(
unicode
(
course_key
)
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
'An error occurred while generating course structure for
%
s:
%
s'
,
unicode
(
course_key
),
e
)
logger
.
error
(
'An error occurred while generating course structure for
%
s:
%
s'
,
unicode
(
course_key
),
e
)
...
...
openedx/core/djangoapps/content/course_structures/models.py
View file @
dc491c4c
...
@@ -4,7 +4,7 @@ import logging
...
@@ -4,7 +4,7 @@ import logging
from
celery.task
import
task
from
celery.task
import
task
from
django.dispatch
import
receiver
from
django.dispatch
import
receiver
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
opaque_keys.edx.
locator
import
CourseLocator
from
opaque_keys.edx.
keys
import
CourseKey
from
xmodule.modulestore.django
import
modulestore
,
SignalHandler
from
xmodule.modulestore.django
import
modulestore
,
SignalHandler
from
util.models
import
CompressedTextField
from
util.models
import
CompressedTextField
...
@@ -60,7 +60,7 @@ def generate_course_structure(course_key):
...
@@ -60,7 +60,7 @@ def generate_course_structure(course_key):
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# Note: The countdown=0 kwarg is set to to ensure the method below does not attempt to access the course
# Note: The countdown=0 kwarg is set to to ensure the method below does not attempt to access the course
# before the signal emitter has finished all operations. This is also necessary to ensure all tests pass.
# before the signal emitter has finished all operations. This is also necessary to ensure all tests pass.
update_course_structure
.
delay
(
course_key
,
countdown
=
0
)
update_course_structure
.
delay
(
unicode
(
course_key
)
,
countdown
=
0
)
@task
()
@task
()
...
@@ -68,9 +68,12 @@ def update_course_structure(course_key):
...
@@ -68,9 +68,12 @@ def update_course_structure(course_key):
"""
"""
Regenerates and updates the course structure (in the database) for the specified course.
Regenerates and updates the course structure (in the database) for the specified course.
"""
"""
if
not
isinstance
(
course_key
,
CourseLocator
):
# Ideally we'd like to accept a CourseLocator; however, CourseLocator is not JSON-serializable (by default) so
logger
.
error
(
'update_course_structure requires a CourseLocator. Given
%
s.'
,
type
(
course_key
))
# Celery's delayed tasks fail to start. For this reason, callers should pass the course key as a Unicode string.
return
if
not
isinstance
(
course_key
,
basestring
):
raise
ValueError
(
'course_key must be a string. {} is not acceptable.'
.
format
(
type
(
course_key
)))
course_key
=
CourseKey
.
from_string
(
course_key
)
try
:
try
:
structure
=
generate_course_structure
(
course_key
)
structure
=
generate_course_structure
(
course_key
)
...
...
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