← Back to team overview

launchpad-dev team mailing list archive

Re: brainstorm: cheaper API collection iteration

 


On March 25, 2011, James Westby wrote:
> On Fri, 25 Mar 2011 15:11:19 +1300, Robert Collins 
<robert.collins@xxxxxxxxxxxxx> wrote:
> > But how do we teach launchpadlib to do this? And how do we encode this
> > in the wadl?
> 
> My understanding, may be way off.
> 
> Pages in collections are just links, so you can generate what you
> like. You can generate the bare link to the collection to get the first
> page, and then when that page is returned it would say
> 
>   next_page_link:
>  
> "https://api.launchpad.net/devel/some_collection?start_key=endkey_of_this_
> collection
> 
> then when the next page is needed launchpadlib simply hits that URL.
> 
> Therefore I think this would be fairly straightforward to change in the
> current webservice. It also looks as though just changing
> lazr.batchnavigator will get most of the way there, so it may be that
> fixing the web UI fixes the API too.
> 

Generally, lazr.restfulclient uses next_colletion_link to navigate the 
collection. 

There is one special case which is if the starting index requested within the 
collection isn't already loaded, it sets ws.start to control the starting 
point. 

In a away, launchpadlib and lazr.restful offers the slice protocol on all 
colletions and assume that these understands ws.start to start at any 
arbitrary point.

The change suggested by Robert means that we should only support the iteration 
protocol, and maybe a slice one, where the slices aren't numeric index.

-- 
Francis J. Lacoste
francis.lacoste@xxxxxxxxxxxxx

Attachment: signature.asc
Description: This is a digitally signed message part.


References