Comment 2 for bug 551704

Revision history for this message
Leonard Richardson (leonardr) wrote :

This is the problem:

>>> b.bug_tasks[2] is b.bug_tasks[2]
False

A lazr.restfulclient scoped collection object is a lazy collection. If you ask for element 2, it will make an HTTP request to /bugs/549305/bug_tasks?ws.start=2, grab element #2, and wrap it in a Python object. If you ask for element 2 again, it will make another HTTP request and wrap the result in another Python object. If you set bug_tasks[2].status, the field will be set, but you'll never see that object again, because you didn't hold a reference to it.

Semi-obvious solutions include caching individual elements of scoped collections in the scoped-collection object (a solution distinct from caching HTTP requests for scoped collection pages, and probably easier to implement).

The workaround is to assign an object to a variable if you're going to use it more than once.