Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
3b4fb616
Commit
3b4fb616
authored
12 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Push dependency on mitxmako up out of mako_module
parent
d7178e4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/mako_module.py
+13
-3
13 additions, 3 deletions
common/lib/xmodule/xmodule/mako_module.py
common/lib/xmodule/xmodule/modulestore/mongo.py
+4
-2
4 additions, 2 deletions
common/lib/xmodule/xmodule/modulestore/mongo.py
with
17 additions
and
5 deletions
common/lib/xmodule/xmodule/mako_module.py
+
13
−
3
View file @
3b4fb616
from
x_module
import
XModuleDescriptor
from
mitxmako.shortcuts
import
render_to_string
from
x_module
import
XModuleDescriptor
,
DescriptorSystem
class
MakoDescriptorSystem
(
DescriptorSystem
):
def
__init__
(
self
,
render_template
,
*
args
,
**
kwargs
):
self
.
render_template
=
render_template
super
(
MakoDescriptorSystem
,
self
).
__init__
(
*
args
,
**
kwargs
)
class
MakoModuleDescriptor
(
XModuleDescriptor
):
...
...
@@ -12,6 +17,11 @@ class MakoModuleDescriptor(XModuleDescriptor):
the descriptor as the `module` parameter to that template
"""
def
__init__
(
self
,
system
,
definition
=
None
,
**
kwargs
):
if
getattr
(
system
,
'
render_template
'
,
None
)
is
None
:
raise
TypeError
(
'
{system} must have a render_template function in order to use a MakoDescriptor
'
.
format
(
system
=
system
))
super
(
MakoModuleDescriptor
,
self
).
__init__
(
system
,
definition
,
**
kwargs
)
def
get_context
(
self
):
"""
Return the context to render the mako template with
...
...
@@ -19,4 +29,4 @@ class MakoModuleDescriptor(XModuleDescriptor):
return
{
'
module
'
:
self
}
def
get_html
(
self
):
return
render_to_string
(
self
.
mako_template
,
self
.
get_context
())
return
self
.
system
.
render_template
(
self
.
mako_template
,
self
.
get_context
())
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/modulestore/mongo.py
+
4
−
2
View file @
3b4fb616
import
pymongo
from
importlib
import
import_module
from
xmodule.x_module
import
XModuleDescriptor
,
DescriptorSystem
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.mako_module
import
MakoDescriptorSystem
from
mitxmako.shortcuts
import
render_to_string
from
.
import
ModuleStore
,
Location
from
.exceptions
import
ItemNotFoundError
,
InsufficientSpecificationError
...
...
@@ -54,7 +56,7 @@ class MongoModuleStore(ModuleStore):
# TODO (cpennington): Pass a proper resources_fs to the system
return
XModuleDescriptor
.
load_from_json
(
item
,
DescriptorSystem
(
self
.
get_item
,
None
),
self
.
default_class
)
item
,
Mako
DescriptorSystem
(
load_item
=
self
.
get_item
,
resources_fs
=
None
,
render_template
=
render_to_string
),
self
.
default_class
)
def
create_item
(
self
,
location
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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