changeset e4dea759b0f6 in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset&node=e4dea759b0f6
description:
Add support for werkzeug 2.0
issue10086
review337571002
(grafted from 2132304259eec4c35e6f2ca908c20d35bdda6f5f)
diffstat:
CHANGELOG | 2 ++
setup.py | 2 +-
trytond/protocols/wrappers.py | 14 +++++++-------
3 files changed, 10 insertions(+), 8 deletions(-)
diffs (74 lines):
diff -r fd58807ea767 -r e4dea759b0f6 CHANGELOG
--- a/CHANGELOG Sat Mar 19 15:04:09 2022 +0100
+++ b/CHANGELOG Fri May 28 09:10:15 2021 +0200
@@ -1,3 +1,5 @@
+* Add support for werkzeug 2.0
+
Version 6.0.16 - 2022-03-01
* Bug fixes (see mercurial logs for details)
* Do not resolve entities by default with lxml (issue11219)
diff -r fd58807ea767 -r e4dea759b0f6 setup.py
--- a/setup.py Sat Mar 19 15:04:09 2022 +0100
+++ b/setup.py Fri May 28 09:10:15 2021 +0200
@@ -163,7 +163,7 @@
'python-dateutil',
'polib',
'python-sql >= 0.5',
- 'werkzeug < 2',
+ 'werkzeug',
'wrapt',
'passlib >= 1.7.0',
],
diff -r fd58807ea767 -r e4dea759b0f6 trytond/protocols/wrappers.py
--- a/trytond/protocols/wrappers.py Sat Mar 19 15:04:09 2022 +0100
+++ b/trytond/protocols/wrappers.py Fri May 28 09:10:15 2021 +0200
@@ -12,7 +12,6 @@
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
@@ -116,7 +115,8 @@
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()
@@ -130,9 +130,9 @@
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"),
})
@@ -217,16 +217,16 @@
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()