2
2
#
3
3
# This file is part of Invenio.
4
4
# Copyright (C) 2015-2018 CERN.
5
- # Copyright (C) 2024 KTH Royal Institute of Technology.
5
+ # Copyright (C) 2024-2025 KTH Royal Institute of Technology.
6
6
#
7
7
# Invenio is free software; you can redistribute it and/or modify it
8
8
# under the terms of the MIT License; see LICENSE file for more details.
@@ -68,11 +68,9 @@ def build_db_uri():
68
68
"""
69
69
default_uri = "postgresql+psycopg2://invenio-app-rdm:invenio-app-rdm@localhost/invenio-app-rdm"
70
70
71
- uri = os .environ .get ("INVENIO_SQLALCHEMY_DATABASE_URI" ) or os .environ .get (
72
- "SQLALCHEMY_DATABASE_URI"
73
- )
74
- if uri :
75
- return uri
71
+ for key in ["INVENIO_SQLALCHEMY_DATABASE_URI" , "SQLALCHEMY_DATABASE_URI" ]:
72
+ if uri := os .environ .get (key ):
73
+ return uri
76
74
77
75
db_params = _get_env_var (
78
76
"INVENIO_DB" , ["user" , "password" , "host" , "port" , "name" , "protocol" ]
@@ -97,9 +95,9 @@ def build_broker_url():
97
95
"""
98
96
default_url = "amqp://guest:guest@localhost:5672/"
99
97
100
- broker_url = os . environ . get ( "INVENIO_BROKER_URL" ) or os . environ . get ( "BROKER_URL" )
101
- if broker_url :
102
- return broker_url
98
+ for key in [ "INVENIO_BROKER_URL" , "BROKER_URL" ]:
99
+ if broker_url := os . environ . get ( key ) :
100
+ return broker_url
103
101
104
102
broker_params = _get_env_var (
105
103
"INVENIO_AMQP_BROKER" , ["user" , "password" , "host" , "port" , "protocol" ]
@@ -124,11 +122,10 @@ def build_redis_url(db=None):
124
122
db = db if db is not None else 0
125
123
default_url = f"redis://localhost:6379/{ db } "
126
124
127
- cache_url = os .environ .get ("INVENIO_CACHE_REDIS_URL" ) or os .environ .get (
128
- "CACHE_REDIS_URL"
129
- )
130
- if cache_url and cache_url .startswith (("redis://" , "rediss://" , "unix://" )):
131
- return cache_url
125
+ for key in ["INVENIO_CACHE_REDIS_URL" , "CACHE_REDIS_URL" ]:
126
+ if cache_url := os .environ .get (key ):
127
+ if cache_url .startswith (("redis://" , "rediss://" , "unix://" )):
128
+ return cache_url
132
129
133
130
redis_params = _get_env_var (
134
131
"INVENIO_KV_CACHE" , ["host" , "port" , "password" , "protocol" ]
0 commit comments