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
6a24eceb
Commit
6a24eceb
authored
Nov 28, 2012
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode utf-8 when reading html, and encode when writing.
parent
41b73e3b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
6 deletions
+6
-6
common/djangoapps/mitxmako/shortcuts.py
+1
-1
common/djangoapps/mitxmako/template.py
+1
-1
common/lib/xmodule/xmodule/html_module.py
+2
-2
common/lib/xmodule/xmodule/template_module.py
+1
-1
common/lib/xmodule/xmodule/xml_module.py
+1
-1
No files found.
common/djangoapps/mitxmako/shortcuts.py
View file @
6a24eceb
...
...
@@ -42,7 +42,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
context_dictionary
.
update
(
context
)
# fetch and render template
template
=
middleware
.
lookup
[
namespace
]
.
get_template
(
template_name
)
return
template
.
render
(
**
context_dictionary
)
return
template
.
render
_unicode
(
**
context_dictionary
)
def
render_to_response
(
template_name
,
dictionary
,
context_instance
=
None
,
namespace
=
'main'
,
**
kwargs
):
...
...
common/djangoapps/mitxmako/template.py
View file @
6a24eceb
...
...
@@ -54,5 +54,5 @@ class Template(MakoTemplate):
context_dictionary
[
'MITX_ROOT_URL'
]
=
settings
.
MITX_ROOT_URL
context_dictionary
[
'django_context'
]
=
context_instance
return
super
(
Template
,
self
)
.
render
(
**
context_dictionary
)
return
super
(
Template
,
self
)
.
render
_unicode
(
**
context_dictionary
)
common/lib/xmodule/xmodule/html_module.py
View file @
6a24eceb
...
...
@@ -123,7 +123,7 @@ class HtmlDescriptor(XmlDescriptor, EditingDescriptor):
try
:
with
system
.
resources_fs
.
open
(
filepath
)
as
file
:
html
=
file
.
read
()
html
=
file
.
read
()
.
decode
(
'utf-8'
)
# Log a warning if we can't parse the file, but don't error
if
not
check_html
(
html
):
msg
=
"Couldn't parse html in {0}."
.
format
(
filepath
)
...
...
@@ -164,7 +164,7 @@ class HtmlDescriptor(XmlDescriptor, EditingDescriptor):
resource_fs
.
makedir
(
os
.
path
.
dirname
(
filepath
),
allow_recreate
=
True
)
with
resource_fs
.
open
(
filepath
,
'w'
)
as
file
:
file
.
write
(
self
.
definition
[
'data'
])
file
.
write
(
self
.
definition
[
'data'
]
.
encode
(
'utf-8'
)
)
# write out the relative name
relname
=
path
(
pathname
)
.
basename
()
...
...
common/lib/xmodule/xmodule/template_module.py
View file @
6a24eceb
...
...
@@ -58,7 +58,7 @@ class CustomTagDescriptor(RawDescriptor):
params
=
dict
(
xmltree
.
items
())
with
system
.
resources_fs
.
open
(
'custom_tags/{name}'
.
format
(
name
=
template_name
))
as
template
:
return
Template
(
template
.
read
())
.
render
(
**
params
)
return
Template
(
template
.
read
()
.
decode
(
'utf-8'
)
)
.
render
(
**
params
)
def
__init__
(
self
,
system
,
definition
,
**
kwargs
):
...
...
common/lib/xmodule/xmodule/xml_module.py
View file @
6a24eceb
...
...
@@ -366,7 +366,7 @@ class XmlDescriptor(XModuleDescriptor):
filepath
=
self
.
__class__
.
_format_filepath
(
self
.
category
,
url_path
)
resource_fs
.
makedir
(
os
.
path
.
dirname
(
filepath
),
allow_recreate
=
True
)
with
resource_fs
.
open
(
filepath
,
'w'
)
as
file
:
file
.
write
(
etree
.
tostring
(
xml_object
,
pretty_print
=
True
))
file
.
write
(
etree
.
tostring
(
xml_object
,
pretty_print
=
True
,
encoding
=
'utf-8'
,
xml_declaration
=
True
))
# And return just a pointer with the category and filename.
record_object
=
etree
.
Element
(
self
.
category
)
...
...
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