changeset c8f1dc9a357c in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=c8f1dc9a357c
description:
Add option to trytond-console to start a readonly transaction
issue10495
review358231002
diffstat:
CHANGELOG | 1 +
trytond/commandline.py | 2 ++
trytond/console.py | 3 ++-
3 files changed, 5 insertions(+), 1 deletions(-)
diffs (33 lines):
diff -r 3b899a065dce -r c8f1dc9a357c CHANGELOG
--- a/CHANGELOG Wed Jun 16 14:55:46 2021 +0200
+++ b/CHANGELOG Wed Jun 16 14:59:59 2021 +0200
@@ -1,3 +1,4 @@
+* Add option to trytond-console to start a readonly transaction
* Add support for werkzeug 2.0
* Combine search and get_keys in DictSchemaMixin
* Make language code unique
diff -r 3b899a065dce -r c8f1dc9a357c trytond/commandline.py
--- a/trytond/commandline.py Wed Jun 16 14:55:46 2021 +0200
+++ b/trytond/commandline.py Wed Jun 16 14:59:59 2021 +0200
@@ -113,6 +113,8 @@
required=True, metavar='DATABASE', help="specify the database name")
parser.add_argument("--histsize", dest="histsize", type=int, default=500,
help="The number of commands to remember in the command history")
+ parser.add_argument("--readonly", dest="readonly", action='store_true',
+ help="Start a readonly transaction")
parser.epilog = "To store changes, `transaction.commit()` must be called."
return parser
diff -r 3b899a065dce -r c8f1dc9a357c trytond/console.py
--- a/trytond/console.py Wed Jun 16 14:55:46 2021 +0200
+++ b/trytond/console.py Wed Jun 16 14:59:59 2021 +0200
@@ -45,7 +45,8 @@
with Transaction().start(db_name, 0, readonly=True):
pool.init()
- with Transaction().start(db_name, 0) as transaction:
+ with Transaction().start(
+ db_name, 0, readonly=options.readonly) as transaction:
local = {
'pool': pool,
'transaction': transaction,