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
aecc037e
Commit
aecc037e
authored
Mar 03, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint and pep8 fixes
parent
fc1ca7b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
11 deletions
+18
-11
common/lib/xmodule/xmodule/modulestore/__init__.py
+1
-1
common/lib/xmodule/xmodule/modulestore/mixed.py
+4
-4
common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py
+2
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+11
-4
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
aecc037e
...
...
@@ -451,7 +451,7 @@ class ModuleStoreWrite(ModuleStoreRead):
pass
@abstractmethod
def
delete_item
(
self
,
location
,
user_id
=
None
,
delete_all_versions
=
False
,
delete_children
=
False
,
force
=
False
):
def
delete_item
(
self
,
location
,
user_id
=
None
,
**
kwargs
):
"""
Delete an item from persistence. Pass the user's unique id which the persistent store
should save with the update if it has that ability.
...
...
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
aecc037e
...
...
@@ -344,7 +344,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
parent
.
children
.
append
(
location
.
url
())
store
.
update_item
(
parent
)
elif
isinstance
(
store
,
SplitMongoModuleStore
):
if
isinstance
(
course_or_parent_loc
,
basestring
):
# course_id
if
isinstance
(
course_or_parent_loc
,
basestring
):
# course_id
course_or_parent_loc
=
loc_mapper
()
.
translate_location_to_course_locator
(
course_or_parent_loc
,
None
)
...
...
@@ -377,15 +377,15 @@ class MixedModuleStore(ModuleStoreWriteBase):
store
=
self
.
_get_modulestore_for_courseid
(
course_id
)
return
store
.
update_item
(
xblock
,
user_id
)
def
delete_item
(
self
,
location
,
user_id
=
None
):
def
delete_item
(
self
,
location
,
user_id
=
None
,
**
kwargs
):
"""
Delete the given item from persistence.
Delete the given item from persistence.
kwargs allow modulestore specific parameters.
"""
course_id
=
self
.
_infer_course_id_try
(
location
)
if
course_id
is
None
:
raise
ItemNotFoundError
(
u"Cannot find modulestore for
%
s"
%
location
)
store
=
self
.
_get_modulestore_for_courseid
(
course_id
)
return
store
.
delete_item
(
location
,
user_id
=
user_id
)
return
store
.
delete_item
(
location
,
user_id
=
user_id
,
**
kwargs
)
def
close_all_connections
(
self
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py
View file @
aecc037e
...
...
@@ -58,8 +58,8 @@ class ItemFactory(SplitFactory):
# pylint: disable=W0613
@classmethod
def
_create
(
cls
,
target_class
,
parent_location
,
category
=
'chapter'
,
user_id
=
'test_user'
,
block_id
=
None
,
definition_locator
=
None
,
force
=
False
,
continue_version
=
False
,
**
kwargs
):
user_id
=
'test_user'
,
block_id
=
None
,
definition_locator
=
None
,
force
=
False
,
continue_version
=
False
,
**
kwargs
):
"""
passes *kwargs* as the new item's field values:
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
aecc037e
...
...
@@ -109,7 +109,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
patcher
.
start
()
self
.
addCleanup
(
patcher
.
stop
)
self
.
addTypeEqualityFunc
(
BlockUsageLocator
,
'_compareIgnoreVersion'
)
# define attrs which get set in initdb to quell pylint
self
.
import_chapter_location
=
self
.
store
=
self
.
fake_location
=
self
.
xml_chapter_location
=
None
self
.
course_locations
=
[]
# pylint: disable=invalid-name
def
_create_course
(
self
,
default
,
course_id
):
"""
Create a course w/ one item in the persistence store using the given course & item location.
...
...
@@ -147,8 +151,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
return
Location
(
course_dict
)
self
.
course_locations
=
{
course_id
:
generate_location
(
course_id
)
for
course_id
in
[
self
.
MONGO_COURSEID
,
self
.
XML_COURSEID1
,
self
.
XML_COURSEID2
]
course_id
:
generate_location
(
course_id
)
for
course_id
in
[
self
.
MONGO_COURSEID
,
self
.
XML_COURSEID1
,
self
.
XML_COURSEID2
]
}
self
.
fake_location
=
Location
(
'i4x'
,
'foo'
,
'bar'
,
'vertical'
,
'baz'
)
self
.
import_chapter_location
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
replace
(
...
...
@@ -184,8 +188,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
# try negative cases
self
.
assertFalse
(
self
.
store
.
has_item
(
self
.
XML_COURSEID1
,
self
.
course_locations
[
self
.
XML_COURSEID1
]
.
replace
(
name
=
'not_findable'
,
category
=
'problem'
)
self
.
XML_COURSEID1
,
self
.
course_locations
[
self
.
XML_COURSEID1
]
.
replace
(
name
=
'not_findable'
,
category
=
'problem'
)
))
self
.
assertFalse
(
self
.
store
.
has_item
(
self
.
MONGO_COURSEID
,
self
.
fake_location
))
...
...
@@ -323,10 +327,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
assertEqual
(
len
(
parents
),
1
)
self
.
assertEqual
(
parents
[
0
],
self
.
course_locations
[
self
.
XML_COURSEID1
])
#=============================================================================================================
# General utils for not using django settings
#=============================================================================================================
def
load_function
(
path
):
"""
Load a function by name.
...
...
@@ -338,6 +344,7 @@ def load_function(path):
return
getattr
(
import_module
(
module_path
),
name
)
# pylint: disable=unused-argument
def
create_modulestore_instance
(
engine
,
doc_store_config
,
options
,
i18n_service
=
None
):
"""
This will return a new instance of a modulestore given an engine and options
...
...
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