Projet

Général

Profil

0001-misc-add-publisher.render_response-to-render-respons.patch

Frédéric Péters, 10 avril 2017 10:50

Télécharger (1,97 ko)

Voir les différences:

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(-)
wcs/qommon/misc.py
474 474

  
475 475
def decorate_as_pdf(content):
476 476
    from qommon import template
477
    html_page = template.decorate(content, get_response())
477
    html_page = get_publisher().render_response(content)
478 478
    html_page = html_page.replace('<head>',
479 479
            '<head><base href="%s"><meta charset="%s">' %
480 480
            (get_publisher().get_frontoffice_url(),
wcs/qommon/publisher.py
373 373
        if not hasattr(response, 'filter') or not response.filter:
374 374
            return output
375 375
        try:
376
            return template.decorate(output, response)
376
            return self.render_response(output)
377 377
        except:
378 378
            # Something went wrong applying the template, maybe an error in it;
379 379
            # fail the request properly, to get the error into the logs, the
380 380
            # trace sent by email, etc.
381 381
            return self.finish_failed_request()
382 382

  
383
    def render_response(self, content):
384
        return template.decorate(content, self.get_request().response)
385

  
383 386
    def get_translation(self, lang):
384 387
        '''Retrieve a translation object for the given language and
385 388
        the current theme site.'''
386
-