details: https://code.tryton.org/tryton/commit/e31db4f07afd
branch: 7.8
user: Cédric Krier <[email protected]>
date: Mon Aug 17 17:32:55 2026 +0200
description:
Set all attributes of transaction before connecting to the database
The connection to the database may fail and thus stop and rollback may
be
called. All the attributes must be set to avoid to raise another
AttributeError
exception.
Closes #15022
(grafted from 654923a8085d4804dd217e487c80085c53eb470b)
diffstat:
trytond/trytond/transaction.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (30 lines):
diff -r 50e5585a7406 -r e31db4f07afd trytond/trytond/transaction.py
--- a/trytond/trytond/transaction.py Thu Aug 20 12:02:57 2026 +0200
+++ b/trytond/trytond/transaction.py Mon Aug 17 17:32:55 2026 +0200
@@ -188,13 +188,7 @@
# it is strictly before all transactions started after
# but it may be also before transactions started before
self.started_at = self.monotonic_time()
- if not database_name:
- database = backend.Database().connect()
- else:
- database = backend.Database(database_name).connect()
- Flavor.set(backend.Database.flavor)
self.user = user
- self.database = database
self.readonly = readonly
self.close = close
self.context = ImmutableDict(context or {})
@@ -207,6 +201,12 @@
self.counter = 0
self._datamanagers = []
+ if not database_name:
+ database = backend.Database().connect()
+ else:
+ database = backend.Database(database_name).connect()
+ Flavor.set(backend.Database.flavor)
+ self.database = database
self.connection = database.get_connection(readonly=readonly,
autocommit=autocommit, statement_timeout=timeout)
count = 0