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
ff407c4f
Commit
ff407c4f
authored
Nov 16, 2012
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the python
parent
17d30473
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
common/lib/xmodule/xmodule/xmodule.py
+6
-4
No files found.
common/lib/xmodule/xmodule/xmodule.py
View file @
ff407c4f
...
@@ -130,6 +130,8 @@ class XModule(Plugin):
...
@@ -130,6 +130,8 @@ class XModule(Plugin):
self
.
user_preferences
=
user_preferences
self
.
user_preferences
=
user_preferences
self
.
student_state
=
student_state
self
.
student_state
=
student_state
self
.
_view_name
=
None
@staticmethod
@staticmethod
def
render
(
module
,
view_name
):
def
render
(
module
,
view_name
):
"""
"""
...
@@ -140,10 +142,10 @@ class XModule(Plugin):
...
@@ -140,10 +142,10 @@ class XModule(Plugin):
"""
"""
# Make children use the appropriate render context
# Make children use the appropriate render context
try
:
try
:
setattr
(
module
,
'view_name'
,
view_name
)
module
.
_view_name
=
view_name
return
module
.
find_view
(
view_name
)()
return
module
.
find_view
(
view_name
)()
finally
:
finally
:
delattr
(
module
,
'view_name'
)
module
.
_view_name
=
None
def
render_child
(
self
,
child
,
view_name
=
None
):
def
render_child
(
self
,
child
,
view_name
=
None
):
"""
"""
...
@@ -151,12 +153,12 @@ class XModule(Plugin):
...
@@ -151,12 +153,12 @@ class XModule(Plugin):
render the same view on the child that is currently being rendered on the parent
render the same view on the child that is currently being rendered on the parent
"""
"""
if
view_name
is
None
:
if
view_name
is
None
:
view_name
=
getattr
(
self
,
'view_name'
)
view_name
=
self
.
_view_name
return
XModule
.
render
(
child
,
view_name
)
return
XModule
.
render
(
child
,
view_name
)
def
find_view
(
self
,
view_name
):
def
find_view
(
self
,
view_name
):
for
method_name
,
method_fn
in
inspect
.
getmembers
(
self
,
lambda
m
:
inspect
.
ismethod
(
m
)
):
for
method_name
,
method_fn
in
inspect
.
getmembers
(
self
,
inspect
.
ismethod
):
if
getattr
(
method_fn
,
'view_name'
,
None
)
is
not
None
:
if
getattr
(
method_fn
,
'view_name'
,
None
)
is
not
None
:
return
method_fn
return
method_fn
raise
MissingXModuleView
(
self
.
__class__
,
view_name
)
raise
MissingXModuleView
(
self
.
__class__
,
view_name
)
...
...
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