Merge lp:~leonardr/lazr.restful/size-link into lp:lazr.restful
Status: | Merged |
---|---|
Merged at revision: | 137 |
Proposed branch: | lp:~leonardr/lazr.restful/size-link |
Merge into: | lp:lazr.restful |
Diff against target: |
600 lines (+200/-56) 8 files modified
src/lazr/restful/_operation.py (+25/-2) src/lazr/restful/_resource.py (+33/-6) src/lazr/restful/declarations.py (+23/-12) src/lazr/restful/docs/webservice-declarations.txt (+78/-21) src/lazr/restful/example/base/interfaces.py (+1/-1) src/lazr/restful/example/base/tests/collection.txt (+18/-7) src/lazr/restful/example/base/tests/wadl.txt (+6/-5) src/lazr/restful/templates/wadl-root.pt (+16/-2) |
To merge this branch: | bzr merge lp:~leonardr/lazr.restful/size-link |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York | Pending | ||
Review via email: mp+31060@code.launchpad.net |
Description of the change
NOTE: this is not yet a real merge proposal because the branch is not yet ready. I'm handing the branch over to Benji, and a merge proposal is a convenient way to publicly describe the branch.
This branch makes it possible to define a named operation that returns a collection of objects, but doesn't provide a total_size. This is for cases where the total_size is expensive to calculate. In such cases, the JSON representation returned by the named operation includes a 'total_size_link' instead of a 'total_size'. A client that really wants to find out the total size can GET the total_size_link, which will invoke the operation again and _only_ return the total_size.
There are three things standing in the way of this branch being ready to land.
1. There's a test failure in django.txt.
2. There's a test for the new feature in examples/base, but there also needs to be one in webservice.txt. The test in examples/base tests operation adapters that were generated from declarations. We need a similar test in webservice.txt to test operation adapters that were defined by hand--those adapters go through a different code path.
(I'm confident that this new test will pass immediately, because I ironed out the bugs in this code path when another bug caused *all* named operations to serve total_size_link instead of total_size.)
3. Most importantly, it's not clear as a matter of policy when we should serve total_size_link instead of total_size. I implemented this branch to serve total_size_link when a named operation is annotated with @operation_
a. We should maintain the old behavior for the 'beta' and '1.0' web services.
b. If we know that the entire list fits in one batch, we might as well serve total_size.
This question needs to be decided, and if it's decided in favor of always serving total_size_link (as IMO it should), then the annotation code needs to be removed and replaced with code that gives the old behavior up to a configurable web service version, and the new behavior afterwards.
While working on the lazr.restfulclient branch I realized another problem with this branch: the WADL doesn't mention total_size_link, so lazr.restfulclient can't pick it up. I changed the description of each 'page' representation to mention both 'total_size' and 'total_size_link', since there's no way of knowing which will be present for any given collection. (Not without multiplying the number of 'page' representations by two, which is stupid, or serving them dynamically, which we could do but it's not worth it.)