If I am reading the code correctly, on tenant update, the "description" is stashed into "extra" dict. On tenant create or get, "description" is part of "tenant" dict. Therefore, when "loaded" is set to "False", we do a tenant get when "description" is referenced and absent.
Is that by design, that "extra" is return on update only, but not on create or get?
If that's the case, the fix may be as simple as this?
def __getattr__(self, k):
if k not in self.__dict__: #NOTE(bcwaldon): disallow lazy-loading if already loaded once
if not self.is_loaded(): self.get() return self.__getattr__(k)
# check extra
if 'extra' in self.__dict__ and \ type(self.__dict__['extra']) is types.DictType and \
k in self.__dict__['extra']: return self.__dict__['extra'].get(k)
Sounds good.
If I am reading the code correctly, on tenant update, the "description" is stashed into "extra" dict. On tenant create or get, "description" is part of "tenant" dict. Therefore, when "loaded" is set to "False", we do a tenant get when "description" is referenced and absent.
Is that by design, that "extra" is return on update only, but not on create or get?
If that's the case, the fix may be as simple as this?
def __getattr__(self, k):
#NOTE( bcwaldon) : disallow lazy-loading if already loaded once
self. get()
return self.__getattr__(k)
if k not in self.__dict__:
if not self.is_loaded():
# check extra
type( self.__ dict__[ 'extra' ]) is types.DictType and \ dict__[ 'extra' ]:
return self.__ dict__[ 'extra' ].get(k)
if 'extra' in self.__dict__ and \
k in self.__
raise AttributeError(k)
else:
return self.__dict__[k]