Comment 1 for bug 1075376

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

https://github.com/openstack/python-keystoneclient/blob/master/keystoneclient/base.py:line 91

def _create(self, url, body, response_key, return_raw=False):
        resp, body = self.api.post(url, body=body)
        if return_raw:
            return body[response_key]
        return self.resource_class(self, body[response_key], loaded=True)

This one seem to have something to do with lazy-loading. "loaded" is set to "True", which means never bother to fetch new.

https://github.com/openstack/python-keystoneclient/blob/master/keystoneclient/base.py:line 280-289

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)

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

Question is why is "loaded" set to "True" in the latest code?

btw, this "lazy-loading" logic is convoluted. We may need to document its purpose.