details:   https://code.tryton.org/tryton/commit/969a6386f2b1
branch:    default
user:      Cédric Krier <[email protected]>
date:      Mon Apr 13 14:38:48 2026 +0200
description:
        Test instances against the Response/Request classes from werkzeug

        It should be allowed to use the base classes instead of the custom 
derived of
        Tryton.

        Closes #14765
diffstat:

 trytond/trytond/protocols/wrappers.py |  10 +++++-----
 trytond/trytond/wsgi.py               |   9 +++++----
 2 files changed, 10 insertions(+), 9 deletions(-)

diffs (78 lines):

diff -r c8cf5cbdc449 -r 969a6386f2b1 trytond/trytond/protocols/wrappers.py
--- a/trytond/trytond/protocols/wrappers.py     Thu Mar 26 07:38:42 2026 +0100
+++ b/trytond/trytond/protocols/wrappers.py     Mon Apr 13 14:38:48 2026 +0200
@@ -17,8 +17,8 @@
 from werkzeug.datastructures import Authorization
 from werkzeug.exceptions import abort
 from werkzeug.utils import redirect, send_file
-from werkzeug.wrappers import Request as _Request
-from werkzeug.wrappers import Response as _Response
+from werkzeug.wrappers import Request as BaseRequest
+from werkzeug.wrappers import Response as BaseResponse
 
 from trytond import backend, config, security
 from trytond.exceptions import RateLimitException, UserError, UserWarning
@@ -84,7 +84,7 @@
     remove_cookie(response, database, TRYTON_SESSION_COOKIE)
 
 
-class Request(_Request):
+class Request(BaseRequest):
 
     view_args = None
 
@@ -204,7 +204,7 @@
             }
 
 
-class Response(_Response):
+class Response(BaseResponse):
 
     def get_json(self, force=False, silent=False):
         from .jsonrpc import JSONDecoder, json
@@ -413,7 +413,7 @@
                     response = func(request, *args, **kwargs)
                 except (UserError, UserWarning) as e:
                     raise JSONBadRequest(e)
-            if not isinstance(response, Response) and json:
+            if not isinstance(response, BaseResponse) and json:
                 response = Response(json_.dumps(response, cls=JSONEncoder),
                     content_type='application/json')
             return response
diff -r c8cf5cbdc449 -r 969a6386f2b1 trytond/trytond/wsgi.py
--- a/trytond/trytond/wsgi.py   Thu Mar 26 07:38:42 2026 +0100
+++ b/trytond/trytond/wsgi.py   Mon Apr 13 14:38:48 2026 +0200
@@ -30,7 +30,7 @@
 from trytond import backend, config, security
 from trytond.protocols.jsonrpc import JSONProtocol
 from trytond.protocols.wrappers import (
-    HTTPStatus, Request, Response, abort, exceptions)
+    BaseResponse, HTTPStatus, Request, Response, abort, exceptions)
 from trytond.protocols.xmlrpc import XMLProtocol
 from trytond.status import processing
 from trytond.tools import resolve, safe_join
@@ -142,7 +142,7 @@
             response = e
             for error_handler in self.error_handlers:
                 rv = error_handler(self, request, e)
-                if isinstance(rv, Response):
+                if isinstance(rv, BaseResponse):
                     response = rv
             return response
 
@@ -205,12 +205,13 @@
 
             with processing(request):
                 data = self.dispatch_request(request)
-                if not isinstance(data, (Response, exceptions.HTTPException)):
+                if not isinstance(
+                        data, (BaseResponse, exceptions.HTTPException)):
                     response = self.make_response(request, data)
                 else:
                     response = data
 
-            if origin and isinstance(response, Response):
+            if origin and isinstance(response, BaseResponse):
                 response.headers['Access-Control-Allow-Origin'] = origin
                 response.headers['Vary'] = 'Origin'
                 method = request.headers.get('Access-Control-Request-Method')

Reply via email to