Projet

Général

Profil

0001-general-save-session-at-the-very-end-47154.patch

Frédéric Péters, 04 mai 2021 13:19

Télécharger (1,66 ko)

Voir les différences:

Subject: [PATCH 1/3] general: save session at the very end (#47154)

It's necessary for native django responses as rendering will not go
through CompatWcsPublisher.
 wcs/compat.py     | 1 +
 wcs/middleware.py | 7 +++++++
 2 files changed, 8 insertions(+)
wcs/compat.py
228 228
            # rendering may have altered it (for example a form would add its
229 229
            # token).
230 230
            self.session_manager.finish_successful_request()
231
            request.ignore_session = True  # no further changes
231 232

  
232 233
        for name, value in response.generate_headers():
233 234
            if name in ('Connection', 'Content-Length'):
wcs/middleware.py
91 91
    def process_response(self, request, response):
92 92
        pub = get_publisher()
93 93
        if pub:
94
            request = pub.get_request()
95
            if request and not request.ignore_session:
96
                # it is necessary to save the session one last time as the actual
97
                # rendering may have altered it (for example a form would add its
98
                # token).
99
                pub.session_manager.finish_successful_request()
100

  
94 101
            pub.cleanup()
95 102
        return response
96 103

  
97
-