Nicolas Évrard pushed to branch branch/default at Tryton / Tryton


Commits:
65e7ccc4 by Nicolas Évrard at 2023-02-20T23:22:39+01:00
Set the fallback application name when connecting to postgres

Closes #12074
- - - - -


3 changed files:

- trytond/doc/topics/configuration.rst
- trytond/trytond/__init__.py
- trytond/trytond/backend/postgresql/database.py


Changes:

=====================================
trytond/doc/topics/configuration.rst
=====================================
@@ -145,6 +145,10 @@
 `documentation
 
<https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS>`__.
 
+.. note::
+   ``fallback_application_name`` parameter from aforementioned documentation 
can
+   be set directly thanks to the ``TRYTOND_APPNAME`` environment variable.
+
 SQLite
 ******
 


=====================================
trytond/trytond/__init__.py
=====================================
@@ -1,6 +1,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 import os
+import sys
 import time
 import warnings
 from email import charset
@@ -9,6 +10,7 @@
 
 __version__ = "6.7.0"
 
+os.environ.setdefault('TRYTOND_APPNAME', os.path.basename(sys.argv[0]))
 os.environ.setdefault('TRYTOND_TZ', os.environ.get('TZ', 'UTC'))
 os.environ['TZ'] = 'UTC'
 if hasattr(time, 'tzset'):


=====================================
trytond/trytond/backend/postgresql/database.py
=====================================
@@ -248,6 +248,8 @@
             warnings.warn("The path specified in the URI will be overridden")
         params = {
             'dsn': uri._replace(path=name).geturl(),
+            'fallback_application_name': os.environ.get(
+                'TRYTOND_APPNAME', 'trytond'),
             }
         return params
 



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/65e7ccc438fb89df0b41b70c360c8788ee799af9

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/65e7ccc438fb89df0b41b70c360c8788ee799af9
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to