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
c57833da
Commit
c57833da
authored
Jul 02, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define equality for XModuleDescriptors
parent
f035d560
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
common/lib/xmodule/raw_module.py
+1
-0
common/lib/xmodule/template_module.py
+1
-0
common/lib/xmodule/x_module.py
+25
-0
No files found.
common/lib/xmodule/raw_module.py
View file @
c57833da
...
...
@@ -3,6 +3,7 @@ from lxml import etree
from
xmodule.mako_module
import
MakoModuleDescriptor
from
xmodule.xml_module
import
XmlDescriptor
class
RawDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
"""
Module that provides a raw editing view of it's data and children
...
...
common/lib/xmodule/template_module.py
View file @
c57833da
...
...
@@ -37,5 +37,6 @@ class CustomTagModule(XModule):
def
get_html
(
self
):
return
self
.
html
class
CustomTagDescriptor
(
RawDescriptor
):
module_class
=
CustomTagModule
common/lib/xmodule/x_module.py
View file @
c57833da
...
...
@@ -213,6 +213,10 @@ class XModuleDescriptor(Plugin):
# A list of metadata that this module can inherit from its parent module
inheritable_metadata
=
(
'graded'
,
'due'
,
'graceperiod'
,
'showanswer'
,
'rerandomize'
)
# A list of descriptor attributes that must be equal for the discriptors to be
# equal
equality_attributes
=
(
'definition'
,
'metadata'
,
'location'
,
'shared_state_key'
,
'_inherited_metadata'
)
# ============================= STRUCTURAL MANIPULATION ===========================
def
__init__
(
self
,
system
,
...
...
@@ -395,6 +399,27 @@ class XModuleDescriptor(Plugin):
"""
raise
NotImplementedError
(
"get_html() must be provided by specific modules"
)
# =============================== BUILTIN METHODS ===========================
def
__eq__
(
self
,
other
):
eq
=
(
self
.
__class__
==
other
.
__class__
and
all
(
getattr
(
self
,
attr
,
None
)
==
getattr
(
other
,
attr
,
None
)
for
attr
in
self
.
equality_attributes
))
if
not
eq
:
for
attr
in
self
.
equality_attributes
:
print
getattr
(
self
,
attr
,
None
),
getattr
(
other
,
attr
,
None
),
getattr
(
self
,
attr
,
None
)
==
getattr
(
other
,
attr
,
None
)
return
eq
def
__repr__
(
self
):
return
"{class_}({system!r}, {definition!r}, location={location!r}, metadata={metadata!r})"
.
format
(
class_
=
self
.
__class__
.
__name__
,
system
=
self
.
system
,
definition
=
self
.
definition
,
location
=
self
.
location
,
metadata
=
self
.
metadata
)
class
DescriptorSystem
(
object
):
def
__init__
(
self
,
load_item
,
resources_fs
):
...
...
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