def get_attribute(self, obj, name): """ Get one attribute from an object. """ try: return obj[name] except (TypeError, KeyError, IndexError, AttributeError): try: return get_attribute(obj, name) except (AttributeError, SecurityException): pass if obj is self.undefined_singleton: return _getattr(obj, name) return self.undefined_singleton
def get_attribute(self, obj, name): """ Get one attribute from an object. """ # some traceback systems allow to skip frames. but allow # disabling that via -O to not make things slow if __debug__: __traceback_hide__ = True try: return obj[name] except (TypeError, KeyError, IndexError, AttributeError): try: return get_attribute(obj, name) except (AttributeError, SecurityException): pass if obj is self.undefined_singleton: return _getattr(obj, name) return self.undefined_singleton
def wrapped(env, context, value): try: return get_attribute(value, attribute) except (SecurityException, AttributeError): return env.undefined_singleton