diff --git a/CHANGELOG b/CHANGELOG index c710801080..45f547bd9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add support for werkzeug 2.0 * Combine search and get_keys in DictSchemaMixin * Make language code unique * Support base64 encoded data in ModelStorage.import_data diff --git a/setup.py b/setup.py index 20a4cb3d0b..5ae4640b03 100755 --- a/setup.py +++ b/setup.py @@ -162,7 +162,7 @@ setup(name=name, 'python-dateutil', 'polib', 'python-sql >= 0.5', - 'werkzeug < 2', + 'werkzeug', 'wrapt', 'passlib >= 1.7.0', ], diff --git a/trytond/protocols/wrappers.py b/trytond/protocols/wrappers.py index 10b8cfee51..31d44e90ce 100644 --- a/trytond/protocols/wrappers.py +++ b/trytond/protocols/wrappers.py @@ -12,7 +12,6 @@ except ImportError: from http import client as HTTPStatus from werkzeug.wrappers import Request as _Request, Response -from werkzeug.http import wsgi_to_bytes, bytes_to_wsgi from werkzeug.datastructures import Authorization from werkzeug.exceptions import abort, HTTPException @@ -113,7 +112,8 @@ class Request(_Request): def parse_authorization_header(value): if not value: return - value = wsgi_to_bytes(value) + if not isinstance(value, bytes): + value = value.encode('latin1') try: auth_type, auth_info = value.split(None, 1) auth_type = auth_type.lower() @@ -127,9 +127,9 @@ def parse_authorization_header(value): except Exception: return return Authorization('session', { - 'username': bytes_to_wsgi(username), + 'username': username.decode("latin1"), 'userid': userid, - 'session': bytes_to_wsgi(session), + 'session': session.decode("latin1"), }) @@ -214,16 +214,16 @@ def user_application(name, json=True): pool = Pool() UserApplication = pool.get('res.user.application') - authorization = wsgi_to_bytes(request.headers['Authorization']) + authorization = request.headers['Authorization'] try: auth_type, auth_info = authorization.split(None, 1) auth_type = auth_type.lower() except ValueError: abort(HTTPStatus.UNAUTHORIZED) - if auth_type != b'bearer': + if auth_type != 'bearer': abort(HTTPStatus.FORBIDDEN) - application = UserApplication.check(bytes_to_wsgi(auth_info), name) + application = UserApplication.check(auth_info, name) if not application: abort(HTTPStatus.FORBIDDEN) transaction = Transaction()