Projet

Général

Profil

« Précédent | Suivant » 

Révision 3b6de2bb

Ajouté par Frédéric Péters il y a presque 7 ans

override publisher.render_response instead of template.decorate (#15806)

Voir les différences:

extra/modules/template.py
1 1
from quixote import get_request, get_publisher, get_response
2
from qommon.publisher import get_publisher_class
2 3
from quixote.html import htmltext
3 4

  
4 5
from qommon import _
......
6 7
from qommon.admin.texts import TextsDirectory
7 8
from wcs.categories import Category
8 9

  
9
wcs_decorate = template.decorate
10 10
wcs_error_page = template.error_page
11 11

  
12
def decorate(body, response):
12
def render_response(publisher, body):
13
    response = publisher.get_request().response
13 14
    body = str(body)
14 15

  
15 16
    for key in ('bigdiv', 'gauche'):
16 17
        if not response.filter.has_key(key):
17 18
            response.filter[key] = None
18 19

  
19
    root_url = get_publisher().get_root_url()
20
    wcs_path = get_request().get_path()[len(root_url):]
20
    root_url = publisher.get_root_url()
21
    wcs_path = publisher.get_request().get_path()[len(root_url):]
21 22
    section = wcs_path.split('/')[0]
22 23

  
23 24
    if section in ('backoffice', 'admin'):
24
        return wcs_decorate(body, response)
25
        return template.decorate(body, response)
25 26

  
26 27
    section_title = ''
27 28
    page_title = response.filter.get('title')
......
61 62
        if len(response.breadcrumb) == 1:
62 63
            response.breadcrumb = None
63 64

  
64
    return wcs_decorate(body, response)
65
    return template.decorate(body, response)
65 66

  
66 67

  
67 68
def error_page(*args, **kwargs):
......
75 76
    get_response().filter['title'] = None
76 77
    return htmltext('<div id="info"><h2>%s</h2>' % title) + error_page + htmltext('</div>')
77 78

  
78
template.decorate = decorate
79 79
template.error_page = error_page
80

  
80
get_publisher_class().render_response = render_response
81 81

  
82 82
TextsDirectory.register('aq-error-assistance', N_('Assistance text next to errors'))

Formats disponibles : Unified diff