Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tryton
Tryton
Commits
a22c4cd5d9b2
Commit
a22c4cd5
authored
Jan 14, 2023
by
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
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
trytond/setup.py
View file @
a22c4cd5
...
...
@@ -141,7 +141,6 @@
'polib'
,
'python-sql >= 1.3'
,
'werkzeug'
,
'wrapt'
,
'passlib >= 1.7.0'
,
'pytz;python_version<"3.9"'
,
],
...
...
trytond/trytond/wsgi.py
View file @
a22c4cd5
...
...
@@ -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'
}:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment