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
3b4fb616
Commit
3b4fb616
authored
Jul 02, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push dependency on mitxmako up out of mako_module
parent
d7178e4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
common/lib/xmodule/xmodule/mako_module.py
+13
-3
common/lib/xmodule/xmodule/modulestore/mongo.py
+4
-2
No files found.
common/lib/xmodule/xmodule/mako_module.py
View file @
3b4fb616
from
x_module
import
XModuleDescriptor
from
x_module
import
XModuleDescriptor
,
DescriptorSystem
from
mitxmako.shortcuts
import
render_to_string
class
MakoDescriptorSystem
(
DescriptorSystem
):
def
__init__
(
self
,
render_template
,
*
args
,
**
kwargs
):
self
.
render_template
=
render_template
super
(
MakoDescriptorSystem
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
class
MakoModuleDescriptor
(
XModuleDescriptor
):
class
MakoModuleDescriptor
(
XModuleDescriptor
):
...
@@ -12,6 +17,11 @@ class MakoModuleDescriptor(XModuleDescriptor):
...
@@ -12,6 +17,11 @@ class MakoModuleDescriptor(XModuleDescriptor):
the descriptor as the `module` parameter to that template
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
):
def
get_context
(
self
):
"""
"""
Return the context to render the mako template with
Return the context to render the mako template with
...
@@ -19,4 +29,4 @@ class MakoModuleDescriptor(XModuleDescriptor):
...
@@ -19,4 +29,4 @@ class MakoModuleDescriptor(XModuleDescriptor):
return
{
'module'
:
self
}
return
{
'module'
:
self
}
def
get_html
(
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
())
common/lib/xmodule/xmodule/modulestore/mongo.py
View file @
3b4fb616
import
pymongo
import
pymongo
from
importlib
import
import_module
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
.
import
ModuleStore
,
Location
from
.exceptions
import
ItemNotFoundError
,
InsufficientSpecificationError
from
.exceptions
import
ItemNotFoundError
,
InsufficientSpecificationError
...
@@ -54,7 +56,7 @@ class MongoModuleStore(ModuleStore):
...
@@ -54,7 +56,7 @@ class MongoModuleStore(ModuleStore):
# TODO (cpennington): Pass a proper resources_fs to the system
# TODO (cpennington): Pass a proper resources_fs to the system
return
XModuleDescriptor
.
load_from_json
(
return
XModuleDescriptor
.
load_from_json
(
item
,
DescriptorSystem
(
self
.
get_item
,
None
),
self
.
default_class
)
item
,
MakoDescriptorSystem
(
load_item
=
self
.
get_item
,
resources_fs
=
None
,
render_template
=
render_to_string
),
self
.
default_class
)
def
create_item
(
self
,
location
):
def
create_item
(
self
,
location
):
"""
"""
...
...
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