changeset 691d0ad1b947 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=691d0ad1b947
description:
Remove deprecation warning from werkzeug 0.15
Try to import SharedDataMiddleware and ProxyFix from middleware Apply
num_proxies to all x_* arguments of ProxyFix.
issue8235
review275141002
diffstat:
trytond/wsgi.py | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diffs (33 lines):
diff -r 77550a119035 -r 691d0ad1b947 trytond/wsgi.py
--- a/trytond/wsgi.py Sun Apr 07 19:50:05 2019 +0200
+++ b/trytond/wsgi.py Mon Apr 08 10:02:54 2019 +0200
@@ -15,8 +15,19 @@
from werkzeug.wrappers import Response
from werkzeug.routing import Map, Rule, BaseConverter
from werkzeug.exceptions import abort, HTTPException, InternalServerError
-from werkzeug.contrib.fixers import ProxyFix
-from werkzeug.wsgi import SharedDataMiddleware
+try:
+ from werkzeug.middleware.proxy_fix import ProxyFix
+
+ def NumProxyFix(app, num_proxies):
+ return ProxyFix(app,
+ x_for=num_proxies, x_proto=num_proxies, x_host=num_proxies,
+ x_port=num_proxies, x_prefix=num_proxies)
+except ImportError:
+ from werkzeug.contrib.fixers import ProxyFix as NumProxyFix
+try:
+ from werkzeug.middleware.shared_data import SharedDataMiddleware
+except ImportError:
+ from werkzeug.wsgi import SharedDataMiddleware
import wrapt
@@ -195,6 +206,6 @@
cache_timeout=config.getint('web', 'cache_timeout'))
num_proxies = config.getint('web', 'num_proxies')
if num_proxies:
- app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=num_proxies)
+ app.wsgi_app = NumProxyFix(app.wsgi_app, num_proxies)
import trytond.protocols.dispatcher
import trytond.bus