Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
c57833da
Commit
c57833da
authored
12 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Define equality for XModuleDescriptors
parent
f035d560
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/lib/xmodule/raw_module.py
+1
-0
1 addition, 0 deletions
common/lib/xmodule/raw_module.py
common/lib/xmodule/template_module.py
+1
-0
1 addition, 0 deletions
common/lib/xmodule/template_module.py
common/lib/xmodule/x_module.py
+25
-0
25 additions, 0 deletions
common/lib/xmodule/x_module.py
with
27 additions
and
0 deletions
common/lib/xmodule/raw_module.py
+
1
−
0
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
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/template_module.py
+
1
−
0
View file @
c57833da
...
...
@@ -37,5 +37,6 @@ class CustomTagModule(XModule):
def
get_html
(
self
):
return
self
.
html
class
CustomTagDescriptor
(
RawDescriptor
):
module_class
=
CustomTagModule
This diff is collapsed.
Click to expand it.
common/lib/xmodule/x_module.py
+
25
−
0
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment