Skip to content

Commit

Permalink
[REF] server_environment: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Oct 29, 2024
1 parent 3a6f9fe commit 06dea0b
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions server_environment/server_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

def _load_running_env():
if not system_base_config.get("running_env"):
env_running_env = os.environ.get("RUNNING_ENV", os.environ.get("ODOO_STAGE"))
env_running_env = os.getenv("RUNNING_ENV") or os.getenv("ODOO_STAGE")
if env_running_env:
system_base_config["running_env"] = env_running_env
else:
Expand Down Expand Up @@ -154,22 +154,12 @@ def _load_config():
serv_config = _load_config()


class _Defaults(dict):
__slots__ = ()

def __setitem__(self, key, value):
def func(*a):
return str(value)

return dict.__setitem__(self, key, func)


class ServerConfiguration(models.TransientModel):
"""Display server configuration."""

_name = "server.config"
_description = "Display server configuration"
_conf_defaults = _Defaults()
_conf_defaults = {}

config = Serialized()

Expand Down Expand Up @@ -201,9 +191,9 @@ def _format_key_display_name(cls, key_name):
def _add_columns(cls):
"""Add columns to model dynamically"""
cols = chain(
list(cls._get_base_cols().items()),
list(cls._get_env_cols().items()),
list(cls._get_system_cols().items()),
cls._get_base_cols().items(),
cls._get_env_cols().items(),
cls._get_system_cols().items(),
)
for col, value in cols:
col_name = col.replace(".", "_")
Expand Down Expand Up @@ -328,5 +318,5 @@ def default_get(self, fields_list):
if not self.show_passwords and self._is_secret(key=key):
res[key] = "**********"
else:
res[key] = self._conf_defaults[key]()
res[key] = str(self._conf_defaults[key])
return res

0 comments on commit 06dea0b

Please sign in to comment.