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
40337068
Commit
40337068
authored
Jun 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to specify Keystore engines and default descriptor classes by name from settings
parent
a8eb7e57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
cms/envs/dev.py
+7
-3
common/lib/keystore/django.py
+7
-6
common/lib/keystore/mongo.py
+7
-4
No files found.
cms/envs/dev.py
View file @
40337068
...
...
@@ -8,9 +8,13 @@ TEMPLATE_DEBUG = DEBUG
KEYSTORE
=
{
'default'
:
{
'host'
:
'localhost'
,
'db'
:
'mongo_base'
,
'collection'
:
'key_store'
,
'ENGINE'
:
'keystore.mongo.MongoModuleStore'
,
'OPTIONS'
:
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'host'
:
'localhost'
,
'db'
:
'mongo_base'
,
'collection'
:
'key_store'
,
}
}
}
...
...
common/lib/keystore/django.py
View file @
40337068
...
...
@@ -6,9 +6,9 @@ Passes settings.KEYSTORE as kwargs to MongoModuleStore
from
__future__
import
absolute_import
from
importlib
import
import_module
from
django.conf
import
settings
from
.mongo
import
MongoModuleStore
from
raw_module
import
RawDescriptor
_KEYSTORES
=
{}
...
...
@@ -17,9 +17,10 @@ def keystore(name='default'):
global
_KEYSTORES
if
name
not
in
_KEYSTORES
:
# TODO (cpennington): Load the default class from a string
_KEYSTORES
[
name
]
=
MongoModuleStore
(
default_class
=
RawDescriptor
,
**
settings
.
KEYSTORE
[
name
])
class_path
=
settings
.
KEYSTORE
[
name
][
'ENGINE'
]
module_path
,
_
,
class_name
=
class_path
.
rpartition
(
'.'
)
class_
=
getattr
(
import_module
(
module_path
),
class_name
)
_KEYSTORES
[
name
]
=
class_
(
**
settings
.
KEYSTORE
[
name
][
'OPTIONS'
])
return
_KEYSTORES
[
name
]
common/lib/keystore/mongo.py
View file @
40337068
import
pymongo
from
importlib
import
import_module
from
xmodule.x_module
import
XModuleDescriptor
,
DescriptorSystem
from
.
import
ModuleStore
,
Location
from
.exceptions
import
ItemNotFoundError
,
InsufficientSpecificationError
from
xmodule.x_module
import
XModuleDescriptor
,
DescriptorSystem
class
MongoModuleStore
(
ModuleStore
):
...
...
@@ -16,7 +18,10 @@ class MongoModuleStore(ModuleStore):
# Force mongo to report errors, at the expense of performance
self
.
collection
.
safe
=
True
self
.
default_class
=
default_class
module_path
,
_
,
class_name
=
default_class
.
rpartition
(
'.'
)
class_
=
getattr
(
import_module
(
module_path
),
class_name
)
self
.
default_class
=
class_
def
get_item
(
self
,
location
):
"""
...
...
@@ -29,8 +34,6 @@ class MongoModuleStore(ModuleStore):
If no object is found at that location, raises keystore.exceptions.ItemNotFoundError
location: Something that can be passed to Location
default_class: An XModuleDescriptor subclass to use if no plugin matching the
location is found
"""
query
=
{}
...
...
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