Comment 3 for bug 1075376

Revision history for this message
Guang Yee (guang-yee) wrote :

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):
        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)

            raise AttributeError(k)
        else:
            return self.__dict__[k]