Commit a22c4cd5 authored by Cédric Krier's avatar Cédric Krier
Browse files

Use standard functools.wraps instead of wrapt

parent e1877c06971b
Pipeline #61623 passed with stages
in 16 minutes and 39 seconds
......@@ -141,7 +141,6 @@
'polib',
'python-sql >= 1.3',
'werkzeug',
'wrapt',
'passlib >= 1.7.0',
'pytz;python_version<"3.9"',
],
......
......@@ -8,6 +8,7 @@
import sys
import traceback
import urllib.parse
from functools import wraps
from werkzeug.routing import BaseConverter, Map, Rule
......@@ -25,8 +26,6 @@
except ImportError:
from werkzeug.wsgi import SharedDataMiddleware
import wrapt
from trytond.config import config
from trytond.protocols.jsonrpc import JSONProtocol
from trytond.protocols.wrappers import (
......@@ -69,17 +68,18 @@
self.error_handlers.append(handler)
return handler
@wrapt.decorator
def auth_required(self, wrapped, instance, args, kwargs):
request = args[0]
if request.user_id:
return wrapped(*args, **kwargs)
else:
headers = {}
if request.headers.get('X-Requested-With') != 'XMLHttpRequest':
headers['WWW-Authenticate'] = 'Basic realm="Tryton"'
response = Response(None, http.client.UNAUTHORIZED, headers)
abort(http.client.UNAUTHORIZED, response=response)
def auth_required(self, func):
@wraps(func)
def wrapper(request, *args, **kwargs):
if request.user_id:
return func(request, *args, **kwargs)
else:
headers = {}
if request.headers.get('X-Requested-With') != 'XMLHttpRequest':
headers['WWW-Authenticate'] = 'Basic realm="Tryton"'
response = Response(None, http.client.UNAUTHORIZED, headers)
abort(http.client.UNAUTHORIZED, response=response)
return wrapper
def check_request_size(self, request, size=None):
if request.method not in {'POST', 'PUT', 'PATCH'}:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment