base: Set response charset
WebOb has started raising an exception when writing a Unicode string to `Response` objects if no charset is set.master
parent
9023294c60
commit
810f7d07b8
|
@ -30,10 +30,12 @@ class VariedResponse(milla.Response):
|
||||||
context = {}
|
context = {}
|
||||||
if template is None or self.request.want == 'json':
|
if template is None or self.request.want == 'json':
|
||||||
self.content_type = str('application/json')
|
self.content_type = str('application/json')
|
||||||
|
self.charset = 'utf-8'
|
||||||
json.dump(context, self.body_file)
|
json.dump(context, self.body_file)
|
||||||
else:
|
else:
|
||||||
if self.request.want == 'xhtml':
|
if self.request.want == 'xhtml':
|
||||||
self.content_type = str('application/xhtml+xml')
|
self.content_type = str('application/xhtml+xml')
|
||||||
|
self.charset = 'utf-8'
|
||||||
self.render(template, context)
|
self.render(template, context)
|
||||||
|
|
||||||
def render(self, template, context=None):
|
def render(self, template, context=None):
|
||||||
|
|
Loading…
Reference in New Issue