Allow unicode YAML dump with UnicodeYAMLRenderer

Fixes #1519
This commit is contained in:
Miro Hrončok 2014-04-10 01:35:45 +02:00
parent b0ba8d61ec
commit 7ae8409370

View File

@ -193,6 +193,7 @@ class YAMLRenderer(BaseRenderer):
format = 'yaml'
encoder = encoders.SafeDumper
charset = 'utf-8'
ensure_ascii = True
def render(self, data, accepted_media_type=None, renderer_context=None):
"""
@ -203,7 +204,15 @@ class YAMLRenderer(BaseRenderer):
if data is None:
return ''
return yaml.dump(data, stream=None, encoding=self.charset, Dumper=self.encoder)
return yaml.dump(data, stream=None, encoding=self.charset, Dumper=self.encoder, allow_unicode=not self.ensure_ascii)
class UnicodeYAMLRenderer(YAMLRenderer):
"""
Renderer which serializes to YAML.
Does *not* apply character escaping for non-ascii characters.
"""
ensure_ascii = False
class TemplateHTMLRenderer(BaseRenderer):