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
358c56da
Commit
358c56da
authored
Jan 17, 2013
by
chrisndodge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1297 from MITx/fix/cdodge/filesystem-xml-fixes
Fix/cdodge/filesystem xml fixes
parents
2f136384
39769ea9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
cms/djangoapps/contentstore/management/commands/import.py
+2
-1
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+13
-5
rakefile
+3
-1
No files found.
cms/djangoapps/contentstore/management/commands/import.py
View file @
358c56da
...
...
@@ -27,4 +27,5 @@ class Command(BaseCommand):
print
"Importing. Data_dir={data}, course_dirs={courses}"
.
format
(
data
=
data_dir
,
courses
=
course_dirs
)
import_from_xml
(
modulestore
(
'direct'
),
data_dir
,
course_dirs
,
load_error_modules
=
False
,
static_content_store
=
contentstore
())
import_from_xml
(
modulestore
(
'direct'
),
data_dir
,
course_dirs
,
load_error_modules
=
False
,
static_content_store
=
contentstore
(),
verbose
=
True
)
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
358c56da
...
...
@@ -11,7 +11,8 @@ from xmodule.contentstore.content import StaticContent, XASSET_SRCREF_PREFIX
log
=
logging
.
getLogger
(
__name__
)
def
import_static_content
(
modules
,
course_loc
,
course_data_path
,
static_content_store
,
target_location_namespace
,
subpath
=
'static'
):
def
import_static_content
(
modules
,
course_loc
,
course_data_path
,
static_content_store
,
target_location_namespace
,
subpath
=
'static'
,
verbose
=
False
):
remap_dict
=
{}
...
...
@@ -23,6 +24,9 @@ def import_static_content(modules, course_loc, course_data_path, static_content_
try
:
content_path
=
os
.
path
.
join
(
dirname
,
filename
)
if
verbose
:
log
.
debug
(
'importing static content {0}...'
.
format
(
content_path
))
fullname_with_subpath
=
content_path
.
replace
(
static_dir
,
''
)
# strip away leading path from the name
if
fullname_with_subpath
.
startswith
(
'/'
):
fullname_with_subpath
=
fullname_with_subpath
[
1
:]
...
...
@@ -90,7 +94,7 @@ def verify_content_links(module, base_dir, static_content_store, link, remap_dic
def
import_from_xml
(
store
,
data_dir
,
course_dirs
=
None
,
default_class
=
'xmodule.raw_module.RawDescriptor'
,
load_error_modules
=
True
,
static_content_store
=
None
,
target_location_namespace
=
None
):
load_error_modules
=
True
,
static_content_store
=
None
,
target_location_namespace
=
None
,
verbose
=
False
):
"""
Import the specified xml data_dir into the "store" modulestore,
using org and course as the location org and course.
...
...
@@ -121,6 +125,9 @@ def import_from_xml(store, data_dir, course_dirs=None,
course_data_path
=
None
course_location
=
None
if
verbose
:
log
.
debug
(
"Scanning {0} for course module..."
.
format
(
course_id
))
# Quick scan to get course module as we need some info from there. Also we need to make sure that the
# course module is committed first into the store
for
module
in
module_store
.
modules
[
course_id
]
.
itervalues
():
...
...
@@ -155,15 +162,14 @@ def import_from_xml(store, data_dir, course_dirs=None,
course_items
.
append
(
module
)
# then import all the static content
if
static_content_store
is
not
None
:
_namespace_rename
=
target_location_namespace
if
target_location_namespace
is
not
None
else
module_store
.
modules
[
course_id
]
.
location
_namespace_rename
=
target_location_namespace
if
target_location_namespace
is
not
None
else
course_
location
# first pass to find everything in /static/
import_static_content
(
module_store
.
modules
[
course_id
],
course_location
,
course_data_path
,
static_content_store
,
_namespace_rename
,
subpath
=
'static'
)
_namespace_rename
,
subpath
=
'static'
,
verbose
=
verbose
)
# finally loop through all the modules
for
module
in
module_store
.
modules
[
course_id
]
.
itervalues
():
...
...
@@ -177,6 +183,8 @@ def import_from_xml(store, data_dir, course_dirs=None,
if
target_location_namespace
is
not
None
:
module
=
remap_namespace
(
module
,
target_location_namespace
)
if
verbose
:
log
.
debug
(
'importing module location {0}'
.
format
(
module
.
location
))
if
'data'
in
module
.
definition
:
module_data
=
module
.
definition
[
'data'
]
...
...
rakefile
View file @
358c56da
...
...
@@ -421,7 +421,9 @@ end
namespace
:cms
do
desc
"Import course data within the given DATA_DIR variable"
task
:import
do
if
ENV
[
'DATA_DIR'
]
if
ENV
[
'DATA_DIR'
]
and
ENV
[
'COURSE_DIR'
]
sh
(
django_admin
(
:cms
,
:dev
,
:import
,
ENV
[
'DATA_DIR'
],
ENV
[
'COURSE_DIR'
]))
elsif
ENV
[
'DATA_DIR'
]
sh
(
django_admin
(
:cms
,
:dev
,
:import
,
ENV
[
'DATA_DIR'
]))
else
raise
"Please specify a DATA_DIR variable that point to your data directory.
\n
"
+
...
...
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