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
d7922012
Commit
d7922012
authored
Sep 26, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change DescriptionLocator to DefinitionLocator
parent
f8c72784
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
14 deletions
+14
-14
common/lib/xmodule/xmodule/modulestore/locator.py
+1
-1
common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py
+2
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+4
-4
common/lib/xmodule/xmodule/modulestore/tests/test_locators.py
+3
-3
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+4
-4
No files found.
common/lib/xmodule/xmodule/modulestore/locator.py
View file @
d7922012
...
@@ -424,7 +424,7 @@ class BlockUsageLocator(CourseLocator):
...
@@ -424,7 +424,7 @@ class BlockUsageLocator(CourseLocator):
return
rep
+
BLOCK_PREFIX
+
unicode
(
self
.
usage_id
)
return
rep
+
BLOCK_PREFIX
+
unicode
(
self
.
usage_id
)
class
De
scrip
tionLocator
(
Locator
):
class
De
fini
tionLocator
(
Locator
):
"""
"""
Container for how to locate a description (the course-independent content).
Container for how to locate a description (the course-independent content).
"""
"""
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py
View file @
d7922012
from
xmodule.modulestore.locator
import
De
scrip
tionLocator
from
xmodule.modulestore.locator
import
De
fini
tionLocator
class
DefinitionLazyLoader
(
object
):
class
DefinitionLazyLoader
(
object
):
...
@@ -15,7 +15,7 @@ class DefinitionLazyLoader(object):
...
@@ -15,7 +15,7 @@ class DefinitionLazyLoader(object):
:param definition_locator: the id of the record in the above to fetch
:param definition_locator: the id of the record in the above to fetch
"""
"""
self
.
modulestore
=
modulestore
self
.
modulestore
=
modulestore
self
.
definition_locator
=
De
scrip
tionLocator
(
definition_id
)
self
.
definition_locator
=
De
fini
tionLocator
(
definition_id
)
def
fetch
(
self
):
def
fetch
(
self
):
"""
"""
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
d7922012
...
@@ -11,7 +11,7 @@ from pytz import UTC
...
@@ -11,7 +11,7 @@ from pytz import UTC
from
xmodule.errortracker
import
null_error_tracker
from
xmodule.errortracker
import
null_error_tracker
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.modulestore.locator
import
BlockUsageLocator
,
De
scrip
tionLocator
,
CourseLocator
,
VersionTree
,
LocalId
from
xmodule.modulestore.locator
import
BlockUsageLocator
,
De
fini
tionLocator
,
CourseLocator
,
VersionTree
,
LocalId
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
VersionConflictError
,
DuplicateItemError
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
VersionConflictError
,
DuplicateItemError
from
xmodule.modulestore
import
inheritance
,
ModuleStoreBase
,
Location
from
xmodule.modulestore
import
inheritance
,
ModuleStoreBase
,
Location
...
@@ -563,7 +563,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
...
@@ -563,7 +563,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
}
}
}
}
new_id
=
self
.
definitions
.
insert
(
document
)
new_id
=
self
.
definitions
.
insert
(
document
)
definition_locator
=
De
scrip
tionLocator
(
new_id
)
definition_locator
=
De
fini
tionLocator
(
new_id
)
document
[
'edit_info'
][
'original_version'
]
=
new_id
document
[
'edit_info'
][
'original_version'
]
=
new_id
self
.
definitions
.
update
({
'_id'
:
new_id
},
{
'$set'
:
{
"edit_info.original_version"
:
new_id
}})
self
.
definitions
.
update
({
'_id'
:
new_id
},
{
'$set'
:
{
"edit_info.original_version"
:
new_id
}})
return
definition_locator
return
definition_locator
...
@@ -597,7 +597,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
...
@@ -597,7 +597,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
old_definition
[
'edit_info'
][
'edited_on'
]
=
datetime
.
datetime
.
now
(
UTC
)
old_definition
[
'edit_info'
][
'edited_on'
]
=
datetime
.
datetime
.
now
(
UTC
)
old_definition
[
'edit_info'
][
'previous_version'
]
=
definition_locator
.
definition_id
old_definition
[
'edit_info'
][
'previous_version'
]
=
definition_locator
.
definition_id
new_id
=
self
.
definitions
.
insert
(
old_definition
)
new_id
=
self
.
definitions
.
insert
(
old_definition
)
return
De
scrip
tionLocator
(
new_id
),
True
return
De
fini
tionLocator
(
new_id
),
True
else
:
else
:
return
definition_locator
,
False
return
definition_locator
,
False
...
@@ -1252,7 +1252,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
...
@@ -1252,7 +1252,7 @@ class SplitMongoModuleStore(ModuleStoreBase):
elif
'_id'
not
in
definition
:
elif
'_id'
not
in
definition
:
return
None
return
None
else
:
else
:
return
De
scrip
tionLocator
(
definition
[
'_id'
])
return
De
fini
tionLocator
(
definition
[
'_id'
])
def
internal_clean_children
(
self
,
course_locator
):
def
internal_clean_children
(
self
,
course_locator
):
"""
"""
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_locators.py
View file @
d7922012
...
@@ -4,7 +4,7 @@ Tests for xmodule.modulestore.locator.
...
@@ -4,7 +4,7 @@ Tests for xmodule.modulestore.locator.
from
unittest
import
TestCase
from
unittest
import
TestCase
from
bson.objectid
import
ObjectId
from
bson.objectid
import
ObjectId
from
xmodule.modulestore.locator
import
Locator
,
CourseLocator
,
BlockUsageLocator
,
De
scrip
tionLocator
from
xmodule.modulestore.locator
import
Locator
,
CourseLocator
,
BlockUsageLocator
,
De
fini
tionLocator
from
xmodule.modulestore.parsers
import
BRANCH_PREFIX
,
BLOCK_PREFIX
,
VERSION_PREFIX
,
URL_VERSION_PREFIX
from
xmodule.modulestore.parsers
import
BRANCH_PREFIX
,
BLOCK_PREFIX
,
VERSION_PREFIX
,
URL_VERSION_PREFIX
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
OverSpecificationError
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
OverSpecificationError
...
@@ -254,11 +254,11 @@ class LocatorTest(TestCase):
...
@@ -254,11 +254,11 @@ class LocatorTest(TestCase):
self
.
assertEqual
(
'BlockUsageLocator("mit.eecs.6002x/branch/published/block/HW3")'
,
repr
(
testobj
))
self
.
assertEqual
(
'BlockUsageLocator("mit.eecs.6002x/branch/published/block/HW3")'
,
repr
(
testobj
))
def
test_description_locator_url
(
self
):
def
test_description_locator_url
(
self
):
definition_locator
=
De
scrip
tionLocator
(
"chapter12345_2"
)
definition_locator
=
De
fini
tionLocator
(
"chapter12345_2"
)
self
.
assertEqual
(
'edx://'
+
URL_VERSION_PREFIX
+
'chapter12345_2'
,
definition_locator
.
url
())
self
.
assertEqual
(
'edx://'
+
URL_VERSION_PREFIX
+
'chapter12345_2'
,
definition_locator
.
url
())
def
test_description_locator_version
(
self
):
def
test_description_locator_version
(
self
):
definition_locator
=
De
scrip
tionLocator
(
"chapter12345_2"
)
definition_locator
=
De
fini
tionLocator
(
"chapter12345_2"
)
self
.
assertEqual
(
"chapter12345_2"
,
definition_locator
.
version
())
self
.
assertEqual
(
"chapter12345_2"
,
definition_locator
.
version
())
# ------------------------------------------------------------------
# ------------------------------------------------------------------
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
d7922012
...
@@ -13,7 +13,7 @@ from xblock.fields import Scope
...
@@ -13,7 +13,7 @@ from xblock.fields import Scope
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
ItemNotFoundError
,
VersionConflictError
,
\
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
ItemNotFoundError
,
VersionConflictError
,
\
DuplicateItemError
DuplicateItemError
from
xmodule.modulestore.locator
import
CourseLocator
,
BlockUsageLocator
,
VersionTree
,
De
scrip
tionLocator
from
xmodule.modulestore.locator
import
CourseLocator
,
BlockUsageLocator
,
VersionTree
,
De
fini
tionLocator
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.x_module
import
XModuleMixin
from
xmodule.x_module
import
XModuleMixin
from
pytz
import
UTC
from
pytz
import
UTC
...
@@ -562,7 +562,7 @@ class TestItemCrud(SplitModuleTest):
...
@@ -562,7 +562,7 @@ class TestItemCrud(SplitModuleTest):
new_module
=
modulestore
()
.
create_item
(
new_module
=
modulestore
()
.
create_item
(
locator
,
category
,
'user123'
,
locator
,
category
,
'user123'
,
fields
=
{
'display_name'
:
'new chapter'
},
fields
=
{
'display_name'
:
'new chapter'
},
definition_locator
=
De
scrip
tionLocator
(
"chapter12345_2"
)
definition_locator
=
De
fini
tionLocator
(
"chapter12345_2"
)
)
)
# check that course version changed and course's previous is the other one
# check that course version changed and course's previous is the other one
self
.
assertNotEqual
(
new_module
.
location
.
version_guid
,
premod_course
.
location
.
version_guid
)
self
.
assertNotEqual
(
new_module
.
location
.
version_guid
,
premod_course
.
location
.
version_guid
)
...
@@ -588,7 +588,7 @@ class TestItemCrud(SplitModuleTest):
...
@@ -588,7 +588,7 @@ class TestItemCrud(SplitModuleTest):
another_module
=
modulestore
()
.
create_item
(
another_module
=
modulestore
()
.
create_item
(
locator
,
category
,
'anotheruser'
,
locator
,
category
,
'anotheruser'
,
fields
=
{
'display_name'
:
'problem 2'
,
'data'
:
another_payload
},
fields
=
{
'display_name'
:
'problem 2'
,
'data'
:
another_payload
},
definition_locator
=
De
scrip
tionLocator
(
"problem12345_3_1"
),
definition_locator
=
De
fini
tionLocator
(
"problem12345_3_1"
),
)
)
# check that course version changed and course's previous is the other one
# check that course version changed and course's previous is the other one
parent
=
modulestore
()
.
get_item
(
locator
)
parent
=
modulestore
()
.
get_item
(
locator
)
...
@@ -789,7 +789,7 @@ class TestItemCrud(SplitModuleTest):
...
@@ -789,7 +789,7 @@ class TestItemCrud(SplitModuleTest):
modulestore
()
.
create_item
(
modulestore
()
.
create_item
(
locator
,
category
,
'test_update_manifold'
,
locator
,
category
,
'test_update_manifold'
,
fields
=
{
'display_name'
:
'problem 2'
,
'data'
:
another_payload
},
fields
=
{
'display_name'
:
'problem 2'
,
'data'
:
another_payload
},
definition_locator
=
De
scrip
tionLocator
(
"problem12345_3_1"
),
definition_locator
=
De
fini
tionLocator
(
"problem12345_3_1"
),
)
)
# pylint: disable=W0212
# pylint: disable=W0212
modulestore
()
.
_clear_cache
()
modulestore
()
.
_clear_cache
()
...
...
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