applicactions: fix applications:
This patch fix application configuration parsing. Peertube and Weblate can be started again.
This commit is contained in:
parent
f17fee4802
commit
c31b6e207c
1 changed files with 33 additions and 13 deletions
|
|
@ -150,7 +150,7 @@ class AppManager:
|
|||
)
|
||||
data["_instance_dir_obj"].cleanup()
|
||||
|
||||
def _libervia_conf_constr(self, loader, node) -> str:
|
||||
def _libervia_conf_constr(self, loader, node) -> str|None:
|
||||
"""Get a value from Libervia configuration
|
||||
|
||||
A list is expected with either "name" of a config parameter, a one or more of
|
||||
|
|
@ -178,7 +178,21 @@ class AppManager:
|
|||
"is expected"
|
||||
)
|
||||
|
||||
value = getattr(getattr(G.config, section), name) or default
|
||||
try:
|
||||
if section.startswith("application."):
|
||||
key = section[12:].strip()
|
||||
if not key:
|
||||
raise ValueError("Invalid configuration section: {section!r}}")
|
||||
value = G.config.application.get(key, {}).get(name, default)
|
||||
else:
|
||||
value = getattr(getattr(G.config, section), name) or default
|
||||
except (AttributeError, KeyError):
|
||||
from pudb import set_trace; set_trace()
|
||||
raise ValueError(
|
||||
f"Invalid configuration request: {section=}, {name=}, {default=}, "
|
||||
f"{filter=}"
|
||||
)
|
||||
|
||||
# FIXME: "public_url" is used only here and doesn't take multi-sites into account
|
||||
if name == "public_url" and (not value or value.startswith("http")):
|
||||
if not value:
|
||||
|
|
@ -201,9 +215,11 @@ class AppManager:
|
|||
if filter_ is None:
|
||||
pass
|
||||
elif filter_ == "first":
|
||||
if not value:
|
||||
raise ValueError("Invalid value: {value!r}")
|
||||
value = value[0]
|
||||
elif filter_ == "not":
|
||||
value = C.bool(value)
|
||||
assert isinstance(value, bool)
|
||||
value = C.bool_const(not value).lower()
|
||||
else:
|
||||
raise ValueError(f"unmanaged filter: {filter_}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue