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
92a7d75b
Commit
92a7d75b
authored
Oct 10, 2013
by
John Jarvis
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1305 from edx/jarv/revert-1240
Revert "Merge pull request #1240 from edx/dhm/config_separation"
parents
82e42cc5
a517dc20
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
91 additions
and
170 deletions
+91
-170
cms/djangoapps/contentstore/management/commands/dump_course_structure.py
+1
-1
cms/djangoapps/contentstore/tests/test_contentstore.py
+3
-3
cms/djangoapps/contentstore/tests/test_import_export.py
+2
-2
cms/djangoapps/contentstore/tests/test_import_nostatic.py
+2
-2
cms/envs/acceptance.py
+3
-6
cms/envs/dev.py
+3
-6
cms/envs/test.py
+3
-7
common/djangoapps/contentserver/tests/test.py
+2
-2
common/djangoapps/terrain/browser.py
+1
-1
common/lib/xmodule/xmodule/contentstore/django.py
+1
-1
common/lib/xmodule/xmodule/modulestore/__init__.py
+1
-6
common/lib/xmodule/xmodule/modulestore/django.py
+3
-7
common/lib/xmodule/xmodule/modulestore/mixed.py
+2
-6
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+9
-20
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+13
-24
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+1
-0
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+7
-17
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+2
-4
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+3
-11
common/lib/xmodule/xmodule/modulestore/tests/test_publish.py
+5
-5
common/lib/xmodule/xmodule/modulestore/tests/test_split_migrator.py
+5
-7
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+7
-13
lms/envs/acceptance.py
+3
-4
lms/envs/cms/dev.py
+3
-4
lms/envs/cms/mixed_dev.py
+2
-4
lms/envs/cms/preview_dev.py
+0
-1
lms/envs/dev_mongo.py
+2
-4
lms/envs/test.py
+2
-2
No files found.
cms/djangoapps/contentstore/management/commands/dump_course_structure.py
View file @
92a7d75b
...
...
@@ -29,7 +29,7 @@ class Command(BaseCommand):
# use a user-specified database name, if present
# this is useful for doing dumps from databases restored from prod backups
if
len
(
args
)
==
3
:
settings
.
MODULESTORE
[
'direct'
][
'
DOC_STORE_CONFIG
'
][
'db'
]
=
args
[
2
]
settings
.
MODULESTORE
[
'direct'
][
'
OPTIONS
'
][
'db'
]
=
args
[
2
]
loc
=
CourseDescriptor
.
id_to_location
(
course_id
)
...
...
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
92a7d75b
...
...
@@ -58,7 +58,7 @@ from student.models import CourseEnrollment
from
contentstore.utils
import
delete_course_and_groups
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
class
MongoCollectionFindWrapper
(
object
):
...
...
@@ -101,7 +101,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
def
tearDown
(
self
):
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
def
check_components_on_page
(
self
,
component_types
,
expected_types
):
...
...
@@ -1313,7 +1313,7 @@ class ContentStoreTest(ModuleStoreTestCase):
def
tearDown
(
self
):
mongo
=
MongoClient
()
mongo
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
mongo
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
def
test_create_course
(
self
):
...
...
cms/djangoapps/contentstore/tests/test_import_export.py
View file @
92a7d75b
...
...
@@ -20,7 +20,7 @@ from django.conf import settings
from
xmodule.contentstore.django
import
_CONTENTSTORE
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -70,7 +70,7 @@ class ImportTestCase(CourseTestCase):
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
content_dir
)
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
...
...
cms/djangoapps/contentstore/tests/test_import_nostatic.py
View file @
92a7d75b
...
...
@@ -28,7 +28,7 @@ from uuid import uuid4
from
pymongo
import
MongoClient
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
@override_settings
(
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
,
MODULESTORE
=
TEST_MODULESTORE
)
...
...
@@ -61,7 +61,7 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
def
tearDown
(
self
):
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
def
load_test_import_course
(
self
):
...
...
cms/envs/acceptance.py
View file @
92a7d75b
...
...
@@ -30,33 +30,30 @@ DOC_STORE_CONFIG = {
'collection'
:
'acceptance_modulestore_
%
s'
%
seed
(),
}
MODULESTORE_OPTIONS
=
{
MODULESTORE_OPTIONS
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
TEST_ROOT
/
"data"
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
}
,
**
DOC_STORE_CONFIG
)
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'direct'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'draft'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
}
}
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'acceptance_xcontent_
%
s'
%
seed
(),
},
...
...
cms/envs/dev.py
View file @
92a7d75b
...
...
@@ -23,26 +23,23 @@ DOC_STORE_CONFIG = {
'collection'
:
'modulestore'
,
}
modulestore_options
=
{
modulestore_options
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
GITHUB_REPO_ROOT
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
}
,
**
DOC_STORE_CONFIG
)
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
},
'direct'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
},
'split'
:
{
'ENGINE'
:
'xmodule.modulestore.split_mongo.SplitMongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
}
}
...
...
@@ -52,7 +49,7 @@ MODULESTORE = {
# This is for static content for courseware, not system static content (e.g. javascript, css, edX branding, etc)
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'xcontent'
,
},
...
...
cms/envs/test.py
View file @
92a7d75b
...
...
@@ -57,38 +57,34 @@ DOC_STORE_CONFIG = {
'collection'
:
'test_modulestore'
,
}
MODULESTORE_OPTIONS
=
{
MODULESTORE_OPTIONS
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
TEST_ROOT
/
"data"
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
}
,
**
DOC_STORE_CONFIG
)
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'direct'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'draft'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'split'
:
{
'ENGINE'
:
'xmodule.modulestore.split_mongo.SplitMongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
MODULESTORE_OPTIONS
}
}
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'test_xcontent'
,
},
...
...
common/djangoapps/contentserver/tests/test.py
View file @
92a7d75b
...
...
@@ -25,7 +25,7 @@ from xmodule.modulestore.xml_importer import import_from_xml
log
=
logging
.
getLogger
(
__name__
)
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
TEST_MODULESTORE
=
studio_store_config
(
settings
.
TEST_ROOT
/
"data"
)
...
...
@@ -80,7 +80,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
def
tearDown
(
self
):
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
MongoClient
()
.
drop_database
(
TEST_DATA_CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
def
test_unlocked_asset
(
self
):
...
...
common/djangoapps/terrain/browser.py
View file @
92a7d75b
...
...
@@ -175,7 +175,7 @@ def reset_databases(scenario):
If no data is created during the test, these lines equivilently do nothing.
'''
mongo
=
MongoClient
()
mongo
.
drop_database
(
settings
.
CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
])
mongo
.
drop_database
(
settings
.
CONTENTSTORE
[
'
OPTIONS
'
][
'db'
])
_CONTENTSTORE
.
clear
()
modulestore
=
xmodule
.
modulestore
.
django
.
editable_modulestore
()
...
...
common/lib/xmodule/xmodule/contentstore/django.py
View file @
92a7d75b
...
...
@@ -21,7 +21,7 @@ def contentstore(name='default'):
if
name
not
in
_CONTENTSTORE
:
class_
=
load_function
(
settings
.
CONTENTSTORE
[
'ENGINE'
])
options
=
{}
options
.
update
(
settings
.
CONTENTSTORE
[
'
DOC_STORE_CONFIG
'
])
options
.
update
(
settings
.
CONTENTSTORE
[
'
OPTIONS
'
])
if
'ADDITIONAL_OPTIONS'
in
settings
.
CONTENTSTORE
:
if
name
in
settings
.
CONTENTSTORE
[
'ADDITIONAL_OPTIONS'
]:
options
.
update
(
settings
.
CONTENTSTORE
[
'ADDITIONAL_OPTIONS'
][
name
])
...
...
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
92a7d75b
...
...
@@ -397,12 +397,7 @@ class ModuleStoreBase(ModuleStore):
'''
Implement interface functionality that can be shared.
'''
def
__init__
(
self
,
doc_store_config
=
None
,
# ignore if passed up
metadata_inheritance_cache_subsystem
=
None
,
request_cache
=
None
,
modulestore_update_signal
=
None
,
xblock_mixins
=
()
):
def
__init__
(
self
,
metadata_inheritance_cache_subsystem
=
None
,
request_cache
=
None
,
modulestore_update_signal
=
None
,
xblock_mixins
=
()):
'''
Set up the error-tracking logic.
'''
...
...
common/lib/xmodule/xmodule/modulestore/django.py
View file @
92a7d75b
...
...
@@ -38,7 +38,7 @@ def load_function(path):
return
getattr
(
import_module
(
module_path
),
name
)
def
create_modulestore_instance
(
engine
,
doc_store_config
,
options
):
def
create_modulestore_instance
(
engine
,
options
):
"""
This will return a new instance of a modulestore given an engine and options
"""
...
...
@@ -66,7 +66,6 @@ def create_modulestore_instance(engine, doc_store_config, options):
request_cache
=
request_cache
,
modulestore_update_signal
=
Signal
(
providing_args
=
[
'modulestore'
,
'course_id'
,
'location'
]),
xblock_mixins
=
getattr
(
settings
,
'XBLOCK_MIXINS'
,
()),
doc_store_config
=
doc_store_config
,
**
_options
)
...
...
@@ -107,11 +106,8 @@ def modulestore(name=None):
name
=
get_default_store_name_for_current_request
()
if
name
not
in
_MODULESTORES
:
_MODULESTORES
[
name
]
=
create_modulestore_instance
(
settings
.
MODULESTORE
[
name
][
'ENGINE'
],
settings
.
MODULESTORE
[
name
]
.
get
(
'DOC_STORE_CONFIG'
,
{}),
settings
.
MODULESTORE
[
name
]
.
get
(
'OPTIONS'
,
{})
)
_MODULESTORES
[
name
]
=
create_modulestore_instance
(
settings
.
MODULESTORE
[
name
][
'ENGINE'
],
settings
.
MODULESTORE
[
name
][
'OPTIONS'
])
# inject loc_mapper into newly created modulestore if it needs it
if
name
==
'split'
and
_loc_singleton
is
not
None
:
_MODULESTORES
[
'split'
]
.
loc_mapper
=
_loc_singleton
...
...
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
92a7d75b
...
...
@@ -30,12 +30,8 @@ class MixedModuleStore(ModuleStoreBase):
raise
Exception
(
'Missing a default modulestore in the MixedModuleStore __init__ method.'
)
for
key
,
store
in
stores
.
items
():
self
.
modulestores
[
key
]
=
create_modulestore_instance
(
store
[
'ENGINE'
],
# XMLModuleStore's don't have doc store configs
store
.
get
(
'DOC_STORE_CONFIG'
,
{}),
store
[
'OPTIONS'
]
)
self
.
modulestores
[
key
]
=
create_modulestore_instance
(
store
[
'ENGINE'
],
store
[
'OPTIONS'
])
def
_get_modulestore_for_courseid
(
self
,
course_id
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
92a7d75b
...
...
@@ -256,44 +256,33 @@ class MongoModuleStore(ModuleStoreBase):
"""
# TODO (cpennington): Enable non-filesystem filestores
# pylint: disable=C0103
# pylint: disable=W0201
def
__init__
(
self
,
doc_store_config
,
fs_root
,
render_template
,
default_class
=
None
,
def
__init__
(
self
,
host
,
db
,
collection
,
fs_root
,
render_template
,
port
=
27017
,
default_class
=
None
,
error_tracker
=
null_error_tracker
,
**
kwargs
):
"""
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
"""
user
=
None
,
password
=
None
,
mongo_options
=
None
,
**
kwargs
):
super
(
MongoModuleStore
,
self
)
.
__init__
(
**
kwargs
)
def
do_connection
(
db
,
collection
,
host
,
port
=
27017
,
tz_aware
=
True
,
user
=
None
,
password
=
None
,
**
kwargs
):
"""
Create & open the connection, authenticate, and provide pointers to the collection
"""
if
mongo_options
is
None
:
mongo_options
=
{}
self
.
collection
=
pymongo
.
connection
.
Connection
(
host
=
host
,
port
=
port
,
tz_aware
=
tz_awar
e
,
**
kwarg
s
tz_aware
=
Tru
e
,
**
mongo_option
s
)[
db
][
collection
]
if
user
is
not
None
and
password
is
not
None
:
self
.
collection
.
database
.
authenticate
(
user
,
password
)
do_connection
(
**
doc_store_config
)
# Force mongo to report errors, at the expense of performance
self
.
collection
.
safe
=
True
# Force mongo to maintain an index over _id.* that is in the same order
# that is used when querying by a location
self
.
collection
.
ensure_index
(
zip
((
'_id.'
+
field
for
field
in
Location
.
_fields
),
repeat
(
1
))
)
zip
((
'_id.'
+
field
for
field
in
Location
.
_fields
),
repeat
(
1
)))
if
default_class
is
not
None
:
module_path
,
_
,
class_name
=
default_class
.
rpartition
(
'.'
)
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
92a7d75b
...
...
@@ -48,48 +48,37 @@ class SplitMongoModuleStore(ModuleStoreBase):
A Mongodb backed ModuleStore supporting versions, inheritance,
and sharing.
"""
# pylint: disable=
W0201
def
__init__
(
self
,
doc_store_config
,
fs_root
,
render_template
,
default_class
=
None
,
# pylint: disable=
C0103
def
__init__
(
self
,
host
,
db
,
collection
,
fs_root
,
render_template
,
port
=
27017
,
default_class
=
None
,
error_tracker
=
null_error_tracker
,
user
=
None
,
password
=
None
,
mongo_options
=
None
,
loc_mapper
=
None
,
**
kwargs
):
"""
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
"""
super
(
SplitMongoModuleStore
,
self
)
.
__init__
(
**
kwargs
)
self
.
loc_mapper
=
loc_mapper
if
mongo_options
is
None
:
mongo_options
=
{}
def
do_connection
(
db
,
collection
,
host
,
port
=
27017
,
tz_aware
=
True
,
user
=
None
,
password
=
None
,
**
kwargs
):
"""
Create & open the connection, authenticate, and provide pointers to the collections
"""
self
.
db
=
pymongo
.
database
.
Database
(
pymongo
.
MongoClient
(
self
.
db
=
pymongo
.
database
.
Database
(
pymongo
.
MongoClient
(
host
=
host
,
port
=
port
,
tz_aware
=
tz_aware
,
**
kwargs
),
db
)
if
user
is
not
None
and
password
is
not
None
:
self
.
db
.
authenticate
(
user
,
password
)
tz_aware
=
True
,
**
mongo_options
),
db
)
self
.
course_index
=
self
.
db
[
collection
+
'.active_versions'
]
self
.
structures
=
self
.
db
[
collection
+
'.structures'
]
self
.
definitions
=
self
.
db
[
collection
+
'.definitions'
]
do_connection
(
**
doc_store_config
)
# Code review question: How should I expire entries?
# _add_cache could use a lru mechanism to control the cache size?
self
.
thread_cache
=
threading
.
local
()
if
user
is
not
None
and
password
is
not
None
:
self
.
db
.
authenticate
(
user
,
password
)
# every app has write access to the db (v having a flag to indicate r/o v write)
# Force mongo to report errors, at the expense of performance
...
...
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
92a7d75b
import
re
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.inheritance
import
own_metadata
import
logging
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
92a7d75b
...
...
@@ -52,13 +52,11 @@ def mongo_store_config(data_dir):
store
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore_
%
s'
%
uuid4
()
.
hex
,
},
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
data_dir
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
}
...
...
@@ -76,6 +74,9 @@ def draft_mongo_store_config(data_dir):
modulestore_options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore_
%
s'
%
uuid4
()
.
hex
,
'fs_root'
:
data_dir
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
}
...
...
@@ -83,11 +84,6 @@ def draft_mongo_store_config(data_dir):
store
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore_
%
s'
%
uuid4
()
.
hex
,
},
'OPTIONS'
:
modulestore_options
}
}
...
...
@@ -118,13 +114,11 @@ def studio_store_config(data_dir):
"""
Defines modulestore structure used by Studio tests.
"""
store_config
=
{
options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore_
%
s'
%
uuid4
()
.
hex
,
}
options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
data_dir
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
...
...
@@ -132,22 +126,18 @@ def studio_store_config(data_dir):
store
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
store_config
,
'OPTIONS'
:
options
},
'direct'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
store_config
,
'OPTIONS'
:
options
},
'draft'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
store_config
,
'OPTIONS'
:
options
},
'split'
:
{
'ENGINE'
:
'xmodule.modulestore.split_mongo.SplitMongoModuleStore'
,
'DOC_STORE_CONFIG'
:
store_config
,
'OPTIONS'
:
options
}
}
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
92a7d75b
...
...
@@ -47,13 +47,11 @@ OPTIONS = {
},
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'OPTIONS'
:
{
'default_class'
:
DEFAULT_CLASS
,
'host'
:
HOST
,
'db'
:
DB
,
'collection'
:
COLLECTION
,
},
'OPTIONS'
:
{
'default_class'
:
DEFAULT_CLASS
,
'fs_root'
:
DATA_DIR
,
'render_template'
:
RENDER_TEMPLATE
,
}
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
92a7d75b
...
...
@@ -56,19 +56,14 @@ class TestMongoModuleStore(object):
@staticmethod
def
initdb
():
# connect to the db
doc_store_config
=
{
'host'
:
HOST
,
'db'
:
DB
,
'collection'
:
COLLECTION
,
}
store
=
MongoModuleStore
(
doc_store_config
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
store
=
MongoModuleStore
(
HOST
,
DB
,
COLLECTION
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
# since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
# as well
content_store
=
MongoContentStore
(
HOST
,
DB
)
#
# Also test draft store imports
#
draft_store
=
DraftModuleStore
(
doc_store_config
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
draft_store
=
DraftModuleStore
(
HOST
,
DB
,
COLLECTION
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
# Explicitly list the courses to load (don't want the big one)
courses
=
[
'toy'
,
'simple'
,
'simple_with_draft'
,
'test_unicode'
]
import_from_xml
(
store
,
DATA_DIR
,
courses
,
draft_store
=
draft_store
,
static_content_store
=
content_store
)
...
...
@@ -118,10 +113,7 @@ class TestMongoModuleStore(object):
pprint
([
Location
(
i
[
'_id'
])
.
url
()
for
i
in
ids
])
def
test_mongo_modulestore_type
(
self
):
store
=
MongoModuleStore
(
{
'host'
:
HOST
,
'db'
:
DB
,
'collection'
:
COLLECTION
},
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
store
=
MongoModuleStore
(
HOST
,
DB
,
COLLECTION
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
assert_equals
(
store
.
get_modulestore_type
(
'foo/bar/baz'
),
'mongo'
)
def
test_get_courses
(
self
):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_publish.py
View file @
92a7d75b
...
...
@@ -26,18 +26,18 @@ class TestPublish(unittest.TestCase):
'db'
:
'test_xmodule'
,
}
modulestore_options
=
{
modulestore_options
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
''
,
'render_template'
:
mock
.
Mock
(
return_value
=
""
),
'xblock_mixins'
:
(
InheritanceMixin
,)
}
}
,
**
db_config
)
def
setUp
(
self
):
self
.
db_config
[
'collection'
]
=
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
)
self
.
modulestore_options
[
'collection'
]
=
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
)
self
.
old_mongo
=
MongoModuleStore
(
self
.
db_config
,
**
self
.
modulestore_options
)
self
.
draft_mongo
=
DraftMongoModuleStore
(
self
.
db_config
,
**
self
.
modulestore_options
)
self
.
old_mongo
=
MongoModuleStore
(
**
self
.
modulestore_options
)
self
.
draft_mongo
=
DraftMongoModuleStore
(
**
self
.
modulestore_options
)
self
.
addCleanup
(
self
.
tear_down_mongo
)
self
.
course_location
=
None
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_migrator.py
View file @
92a7d75b
...
...
@@ -34,22 +34,20 @@ class TestMigration(unittest.TestCase):
'collection'
:
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
),
}
modulestore_options
=
{
modulestore_options
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
''
,
'render_template'
:
mock
.
Mock
(
return_value
=
""
),
'xblock_mixins'
:
(
InheritanceMixin
,)
}
}
,
**
db_config
)
def
setUp
(
self
):
super
(
TestMigration
,
self
)
.
setUp
()
self
.
loc_mapper
=
LocMapperStore
(
**
self
.
db_config
)
self
.
old_mongo
=
MongoModuleStore
(
self
.
db_config
,
**
self
.
modulestore_options
)
self
.
draft_mongo
=
DraftModuleStore
(
self
.
db_config
,
**
self
.
modulestore_options
)
self
.
old_mongo
=
MongoModuleStore
(
**
self
.
modulestore_options
)
self
.
draft_mongo
=
DraftModuleStore
(
**
self
.
modulestore_options
)
self
.
split_mongo
=
SplitMongoModuleStore
(
doc_store_config
=
self
.
db_config
,
loc_mapper
=
self
.
loc_mapper
,
**
self
.
modulestore_options
loc_mapper
=
self
.
loc_mapper
,
**
self
.
modulestore_options
)
self
.
migrator
=
SplitMigrator
(
self
.
split_mongo
,
self
.
old_mongo
,
self
.
draft_mongo
,
self
.
loc_mapper
)
self
.
course_location
=
None
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
92a7d75b
...
...
@@ -28,21 +28,18 @@ class SplitModuleTest(unittest.TestCase):
versions. It creates unique collection names and removes them after all
tests finish.
'''
# Snippets of what would be in the django settings envs file
DOC_STORE_CONFIG
=
{
# Snippet of what would be in the django settings envs file
modulestore_options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
),
}
modulestore_options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
''
,
'xblock_mixins'
:
(
InheritanceMixin
,
XModuleMixin
)
}
MODULESTORE
=
{
'ENGINE'
:
'xmodule.modulestore.split_mongo.SplitMongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
}
...
...
@@ -69,8 +66,8 @@ class SplitModuleTest(unittest.TestCase):
Loads the initial data into the db ensuring the collection name is
unique.
'''
collection_prefix
=
SplitModuleTest
.
MODULESTORE
[
'
DOC_STORE_CONFIG
'
][
'collection'
]
+
'.'
dbname
=
SplitModuleTest
.
MODULESTORE
[
'
DOC_STORE_CONFIG
'
][
'db'
]
collection_prefix
=
SplitModuleTest
.
MODULESTORE
[
'
OPTIONS
'
][
'collection'
]
+
'.'
dbname
=
SplitModuleTest
.
MODULESTORE
[
'
OPTIONS
'
][
'db'
]
processes
=
[
subprocess
.
Popen
([
'mongoimport'
,
'-d'
,
dbname
,
'-c'
,
...
...
@@ -92,7 +89,7 @@ class SplitModuleTest(unittest.TestCase):
@classmethod
def
tearDownClass
(
cls
):
collection_prefix
=
SplitModuleTest
.
MODULESTORE
[
'
DOC_STORE_CONFIG
'
][
'collection'
]
+
'.'
collection_prefix
=
SplitModuleTest
.
MODULESTORE
[
'
OPTIONS
'
][
'collection'
]
+
'.'
if
SplitModuleTest
.
modulestore
:
for
collection
in
(
'active_versions'
,
'structures'
,
'definitions'
):
modulestore
()
.
db
.
drop_collection
(
collection_prefix
+
collection
)
...
...
@@ -1118,10 +1115,7 @@ def modulestore():
options
[
'render_template'
]
=
render_to_template_mock
# pylint: disable=W0142
SplitModuleTest
.
modulestore
=
class_
(
SplitModuleTest
.
MODULESTORE
[
'DOC_STORE_CONFIG'
],
**
options
)
SplitModuleTest
.
modulestore
=
class_
(
**
options
)
return
SplitModuleTest
.
modulestore
...
...
lms/envs/acceptance.py
View file @
92a7d75b
...
...
@@ -32,11 +32,11 @@ DOC_STORE_CONFIG = {
'collection'
:
'acceptance_modulestore_
%
s'
%
seed
(),
}
modulestore_options
=
{
modulestore_options
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
TEST_ROOT
/
"data"
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
}
,
**
DOC_STORE_CONFIG
)
MODULESTORE
=
{
'default'
:
{
...
...
@@ -46,7 +46,6 @@ MODULESTORE = {
'stores'
:
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
}
}
...
...
@@ -58,7 +57,7 @@ MODULESTORE['direct'] = MODULESTORE['default']
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'acceptance_xcontent_
%
s'
%
seed
(),
}
...
...
lms/envs/cms/dev.py
View file @
92a7d75b
...
...
@@ -28,16 +28,15 @@ DOC_STORE_CONFIG = {
'collection'
:
'modulestore'
,
}
modulestore_options
=
{
modulestore_options
=
dict
(
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
DATA_DIR
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
}
,
**
DOC_STORE_CONFIG
)
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
},
'draft'
:
{
...
...
@@ -48,7 +47,7 @@ MODULESTORE = {
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'xcontent'
,
}
...
...
lms/envs/cms/mixed_dev.py
View file @
92a7d75b
...
...
@@ -25,13 +25,11 @@ MODULESTORE = {
},
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'xmodule'
,
'collection'
:
'modulestore'
,
},
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
DATA_DIR
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
...
...
lms/envs/cms/preview_dev.py
View file @
92a7d75b
...
...
@@ -11,7 +11,6 @@ from .dev import *
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
DOC_STORE_CONFIG
,
'OPTIONS'
:
modulestore_options
},
}
lms/envs/dev_mongo.py
View file @
92a7d75b
...
...
@@ -13,13 +13,11 @@ GITHUB_REPO_ROOT = ENV_ROOT / "data"
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'xmodule'
,
'collection'
:
'modulestore'
,
},
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
GITHUB_REPO_ROOT
,
'render_template'
:
'mitxmako.shortcuts.render_to_string'
,
}
...
...
lms/envs/test.py
View file @
92a7d75b
...
...
@@ -115,7 +115,7 @@ INIT_MODULESTORE_ON_STARTUP = False
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'
DOC_STORE_CONFIG
'
:
{
'
OPTIONS
'
:
{
'host'
:
'localhost'
,
'db'
:
'xcontent'
,
}
...
...
@@ -247,4 +247,4 @@ PASSWORD_HASHERS = (
# Generated checkid_setup request to http://testserver/openid/provider/login/ with assocication {HMAC-SHA1}{51d49995}{s/kRmA==}
import
openid.oidutil
openid
.
oidutil
.
log
=
lambda
message
,
level
=
0
:
None
openid
.
oidutil
.
log
=
lambda
message
,
level
=
0
:
None
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