Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
107b68af by Cédric Krier at 2023-02-26T00:20:09+01:00
Do not alter argument values of with_transaction decorator
Closes #12108
- - - - -
2 changed files:
- trytond/CHANGELOG
- trytond/trytond/protocols/wrappers.py
Changes:
=====================================
trytond/CHANGELOG
=====================================
@@ -1,3 +1,4 @@
+* Do not alter argument values of with_transaction decorator (#12108)
* Support SMALLINT and REAL as backend types
* Remove BigInteger field
* Remove support for Python 3.7
=====================================
trytond/trytond/protocols/wrappers.py
=====================================
@@ -200,7 +200,6 @@
def decorator(func):
@wraps(func)
def wrapper(request, pool, *args, **kwargs):
- nonlocal user, context
readonly_ = readonly # can not modify non local
if readonly_ is None:
if request.method in {'POST', 'PUT', 'DELETE', 'PATCH'}:
@@ -208,5 +207,5 @@
else:
readonly_ = True
if context is None:
- context = {}
+ context_ = {}
else:
@@ -212,4 +211,4 @@
else:
- context = context.copy()
- context['_request'] = request.context
+ context_ = context.copy()
+ context_['_request'] = request.context
if user == 'request':
@@ -215,7 +214,9 @@
if user == 'request':
- user = request.user_id
+ user_ = request.user_id
+ else:
+ user_ = user
retry = config.getint('database', 'retry')
for count in range(retry, -1, -1):
if count != retry:
time.sleep(0.02 * (retry - count))
with Transaction().start(
@@ -217,10 +218,10 @@
retry = config.getint('database', 'retry')
for count in range(retry, -1, -1):
if count != retry:
time.sleep(0.02 * (retry - count))
with Transaction().start(
- pool.database_name, user, readonly=readonly_,
- context=context) as transaction:
+ pool.database_name, user_, readonly=readonly_,
+ context=context_) as transaction:
try:
result = func(request, pool, *args, **kwargs)
except backend.DatabaseOperationalError:
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/107b68af389a2cb5c95f663f7a3107fc12aecaf7
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/107b68af389a2cb5c95f663f7a3107fc12aecaf7
You're receiving this email because of your account on foss.heptapod.net.