Comment 4 for bug 662740

Revision history for this message
Colin Watson (cjwatson) wrote :

There's a similar effect with named operations. For example:

    >>> target = lp.git_repositories.getByPath(path='germinate').target
    >>> target.getSeries(name='trunk')
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 734, in __getattr__
        return super(Entry, self).__getattr__(name)
      File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 358, in __getattr__
        % (self, attr))
    AttributeError: https://api.launchpad.net/devel/germinate object has no attribute 'getSeries'
    >>> target._ensure_representation()
    >>> target.getSeries(name='trunk')
    <project_series at https://api.launchpad.net/devel/germinate/trunk>

As suggested by the (inappropriate for production use) workaround in this transcript, I think the fix is probably just to sprinkle self._ensure_representation() around a couple more places in Resource and its subclasses that rely on having the representation available.