def __getattr__(self, name):
return self[name]
def __getitem__(self, name):
if name in self._content:
return self._build(self._content[name])
return self._build(self._get_content()[name])
If name is not in self._build(self._get_content() it raises a KeyError, which propagates upward. However, __getattr__ should raise an AttributeError if an attribute doesn't exist.
This causes a KeyError to be raised when calling code like hasattr(resource_object, 'some_attribute) instead of returning false.
The Resource class currently has this code:
If
name
is not inself._build(self._get_content()
it raises a KeyError, which propagates upward. However,__getattr__
should raise an AttributeError if an attribute doesn't exist.This causes a KeyError to be raised when calling code like
hasattr(resource_object, 'some_attribute)
instead of returning false.