From 927e4b6cafd937a36c2880a0ee1ee5c1b123f7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 10 Apr 2017 10:48:53 +0200 Subject: [PATCH] misc: add publisher.render_response to render response with template (#15806) This will allow the auquotidien module to override that method in a safer way than playing with module-level symbols. --- wcs/qommon/misc.py | 2 +- wcs/qommon/publisher.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wcs/qommon/misc.py b/wcs/qommon/misc.py index 127f64f7..2c5fee74 100644 --- a/wcs/qommon/misc.py +++ b/wcs/qommon/misc.py @@ -474,7 +474,7 @@ def can_decorate_as_pdf(): def decorate_as_pdf(content): from qommon import template - html_page = template.decorate(content, get_response()) + html_page = get_publisher().render_response(content) html_page = html_page.replace('', '' % (get_publisher().get_frontoffice_url(), diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py index 1f952d7a..05918e26 100644 --- a/wcs/qommon/publisher.py +++ b/wcs/qommon/publisher.py @@ -373,13 +373,16 @@ class QommonPublisher(Publisher, object): if not hasattr(response, 'filter') or not response.filter: return output try: - return template.decorate(output, response) + return self.render_response(output) except: # Something went wrong applying the template, maybe an error in it; # fail the request properly, to get the error into the logs, the # trace sent by email, etc. return self.finish_failed_request() + def render_response(self, content): + return template.decorate(content, self.get_request().response) + def get_translation(self, lang): '''Retrieve a translation object for the given language and the current theme site.''' -- 2.11.0