mirror of
https://github.com/OCA/knowledge.git
synced 2025-08-28 10:16:13 -06:00
simpler fix
This commit is contained in:
parent
69d8c4674f
commit
c4e3e32a11
@ -22,29 +22,11 @@ try:
|
||||
|
||||
class Context(SandboxedEnvironment.context_class):
|
||||
def resolve_or_missing(self, key):
|
||||
# Try to get from parent context first
|
||||
try:
|
||||
res = super().resolve_or_missing(key)
|
||||
if not isinstance(res, Undefined):
|
||||
return res
|
||||
except AttributeError:
|
||||
# Fallback for older Jinja2 versions
|
||||
try:
|
||||
res = super().resolve(key)
|
||||
if not isinstance(res, Undefined):
|
||||
return res
|
||||
except AttributeError:
|
||||
_logger.debug(
|
||||
"Neither resolve_or_missing nor resolve method available"
|
||||
)
|
||||
|
||||
# If the key is not found in the normal context, try to resolve it as a reference
|
||||
return self.parent["ref"](key)
|
||||
|
||||
# Keep the old method for backward compatibility
|
||||
def resolve(self, key):
|
||||
return self.resolve_or_missing(key)
|
||||
|
||||
class Environment(SandboxedEnvironment):
|
||||
context_class = Context
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user