From d61d3fed03e882960fc32306d8f970db4ee746ee Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 6 Jun 2025 22:17:27 +0200 Subject: [PATCH] Fix $app attribute access in cheetah templates Fixes https://github.com/galaxyproject/galaxy/issues/20365, which occurs only on Python 3.13 on datasets that can be visualized by a display application. --- lib/galaxy/di.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/galaxy/di.py b/lib/galaxy/di.py index b7c60b46e09..93ce9cd1b6a 100644 --- a/lib/galaxy/di.py +++ b/lib/galaxy/di.py @@ -46,3 +46,10 @@ class Container(LagomContainer): return self[dep_type] except UnresolvableType: return None + + def __getitem__(self, dep_type: Type[T]) -> T: + if isinstance(dep_type, str): + # Workaround for accessing attributes of $app inside cheetah templates. + # Cheetah's searchList implementation tests access via __getitem__ before __getattr__. + return getattr(self, dep_type) # type: ignore[unreachable] + return self.resolve(dep_type)