fix mark_safe issue with cache

This commit is contained in:
Élie Bouttier 2016-10-31 23:51:06 +01:00
parent 12f646cbdc
commit ba1fc9e4f7

View File

@ -164,10 +164,10 @@ class Program:
template = """<table class="table table-bordered text-center">\n%(header)s\n%(body)s\n</table>""" template = """<table class="table table-bordered text-center">\n%(header)s\n%(body)s\n</table>"""
if not self.initialized: if not self.initialized:
self._lazy_init() self._lazy_init()
return mark_safe(template % { return template % {
'header': self._html_header(), 'header': self._html_header(),
'body': self._html_body(), 'body': self._html_body(),
}) }
def _as_xml(self): def _as_xml(self):
if not self.initialized: if not self.initialized:
@ -264,9 +264,9 @@ class Program:
if not result: if not result:
result = getattr(self, '_as_%s' % output)() result = getattr(self, '_as_%s' % output)()
cache.set(cache_entry, result, 3 * 60 * 60) # 3H cache.set(cache_entry, result, 3 * 60 * 60) # 3H
return result return mark_safe(result)
else: else:
return getattr(self, '_as_%s' % output)() return mark_safe(getattr(self, '_as_%s' % output)())
def __str__(self): def __str__(self):
return self.render() return self.render()