Add web_link property to resources
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Launchpad itself |
High
|
Leonard Richardson | ||
| lazr.restful |
High
|
Leonard Richardson |
Bug Description
It would be useful to be able to get the link to a human-readable
representation of an API object. The transformation is relatively
simple:
Leonard Richardson wrote:
> ... you can replace '/api/[^/]*/' with ''. We've determined that
> that's always the relationship between the web service canonical_url
> and the browser canonical_url.
It makes sense to add a method or property to API objects that does
just this.
Related branches
- Tim Penhey (community): Approve on 2011-02-01
-
Diff: 339 lines (+145/-34)6 files modifiedsrc/lazr/restful/_resource.py (+20/-13)
src/lazr/restful/docs/webservice.txt (+25/-10)
src/lazr/restful/publisher.py (+1/-1)
src/lazr/restful/tales.py (+4/-0)
src/lazr/restful/templates/wadl-root.pt (+7/-0)
src/lazr/restful/tests/test_webservice.py (+88/-10)
- Tim Penhey (community): Approve on 2011-02-01
-
Diff: 981 lines (+108/-61)37 files modifiedlib/canonical/launchpad/browser/librarian.py (+1/-3)
lib/canonical/launchpad/doc/canonical_url_examples.txt (+1/-1)
lib/canonical/launchpad/webapp/configure.zcml (+1/-1)
lib/canonical/launchpad/webapp/interfaces.py (+0/-8)
lib/lp/app/doc/tales.txt (+2/-2)
lib/lp/blueprints/tests/test_webservice.py (+2/-1)
lib/lp/bugs/browser/configure.zcml (+6/-3)
lib/lp/bugs/browser/tests/buglinktarget-views.txt (+2/-2)
lib/lp/bugs/interfaces/bugnomination.py (+1/-1)
lib/lp/bugs/interfaces/bugsubscription.py (+1/-1)
lib/lp/bugs/stories/webservice/xx-bug-tracker.txt (+2/-0)
lib/lp/bugs/stories/webservice/xx-bug.txt (+17/-2)
lib/lp/code/interfaces/diff.py (+1/-1)
lib/lp/code/stories/webservice/xx-branch.txt (+1/-1)
lib/lp/code/stories/webservice/xx-branchmergeproposal.txt (+5/-1)
lib/lp/code/stories/webservice/xx-branchsubscription.txt (+2/-0)
lib/lp/hardwaredb/interfaces/hwdb.py (+9/-9)
lib/lp/registry/interfaces/productrelease.py (+1/-1)
lib/lp/registry/interfaces/structuralsubscription.py (+1/-1)
lib/lp/registry/interfaces/wikiname.py (+1/-1)
lib/lp/registry/stories/webservice/xx-distribution-mirror.txt (+4/-0)
lib/lp/registry/stories/webservice/xx-distribution-source-package.txt (+2/-1)
lib/lp/registry/stories/webservice/xx-distribution.txt (+2/-0)
lib/lp/registry/stories/webservice/xx-distroseries.txt (+1/-1)
lib/lp/registry/stories/webservice/xx-person.txt (+5/-1)
lib/lp/registry/stories/webservice/xx-project-registry.txt (+14/-4)
lib/lp/services/worlddata/interfaces/country.py (+2/-1)
lib/lp/soyuz/interfaces/archivedependency.py (+1/-1)
lib/lp/soyuz/interfaces/archivepermission.py (+1/-1)
lib/lp/soyuz/interfaces/packageset.py (+3/-3)
lib/lp/soyuz/interfaces/publishing.py (+2/-2)
lib/lp/soyuz/interfaces/queue.py (+1/-1)
lib/lp/soyuz/stories/webservice/xx-archive.txt (+5/-0)
lib/lp/soyuz/stories/webservice/xx-builds.txt (+3/-1)
lib/lp/soyuz/stories/webservice/xx-distroarchseries.txt (+1/-1)
lib/lp/translations/stories/webservice/xx-potemplate.txt (+1/-0)
versions.cfg (+3/-3)
- Jeroen T. Vermeulen (community): Approve (code) on 2011-02-09
-
Diff: 40 lines (+7/-9)1 file modifiedlib/lp/app/javascript/picker.js (+7/-9)
Changed in launchpadlib: | |
importance: | Undecided → High |
status: | Confirmed → Triaged |
William Grant (wgrant) wrote : | #2 |
Isn't this rather a lazr.restful feature request?
Francis J. Lacoste (flacoste) wrote : | #3 |
Since the rule to derive the web url from the resource URL are fixed, it makes sense to implement this on the client side in a convenient method instead of bloating the representation.
Martin Pool (mbp) wrote : | #4 |
Is it really guaranteed this relationship will always be the same? If not, maybe it should be in the server.
Anyhow, for those using Markus's code, note that the thing you start from is typically 'self_link' not 'self_url'.
Martin Pool (mbp) wrote : | #5 |
For those copy-and-pasting, the change will be somewhat safer as
launchpad_
Leonard Richardson (leonardr) wrote : | #6 |
This is about to change, if I ever manage to land the multi-version branch. The self_link will no longer start with '/api/beta/', but instead will start with '/api/devel/'.
On 17 February 2010 23:25, Leonard Richardson
<email address hidden> wrote:
> This is about to change, if I ever manage to land the multi-version
> branch. The self_link will no longer start with '/api/beta/', but
> instead will start with '/api/devel/'.
That sounds like a really good reason to put the .web_url code into
Launchpadlib, because that change will break most launchpad client
programs.
Leonard Richardson (leonardr) wrote : | #8 |
Sorry, I thought we were talking only about Launchpad Ajax here. We're changing the Launchpad web site so that instead of making requests to /beta/ it makes requests to /devel/, which of course makes the URLs have /devel/ in them. If you've got a launchpadlib program you can continue to make requests to /beta/ and the URLs will continue to have /beta/ in them.
However, I agree that the .web_url should be provided as part of the representation.
Francis J. Lacoste (flacoste) wrote : | #9 |
Should it really be part of the representation? Why not implement it in the client-side API.
Leonard Richardson (leonardr) wrote : | #10 |
On Thu, 2010-02-18 at 15:36 +0000, Francis J. Lacoste wrote:
> Should it really be part of the representation? Why not implement it in
> the client-side API.
Because the implementation changes. If we had already implemented it in
the client-side API, our implementation would become incomplete when I
land the multi-version branch. Implementing URL generation on the server
lets us change it however we want. Especially because the trend is for
the implementation to become more complex over time.
I don't believe that this is an incredibly powerful argument here,
because it's unlikely this implementation will _keep_ changing or become
_very_ complex, but this is why we send links in general instead of
defining rules and having the clients implement those rules.
Gary Poster (gary) wrote : | #11 |
See https:/
affects: | launchpadlib → lazr.restful |
Changed in lazr.restful: | |
status: | Triaged → In Progress |
assignee: | nobody → Leonard Richardson (leonardr) |
Changed in launchpad: | |
status: | New → In Progress |
importance: | Undecided → High |
assignee: | nobody → Leonard Richardson (leonardr) |
tags: | added: api |
Launchpad QA Bot (lpqabot) wrote : | #12 |
Fixed in stable r12324 <http://
tags: | added: qa-needstesting |
Changed in lazr.restful: | |
status: | In Progress → Fix Committed |
tags: |
added: qa-ok removed: qa-needstesting |
Martin Pool (mbp) wrote : | #13 |
I posted http://
William Grant (wgrant) wrote : | #14 |
This is now deployed, but I can't see it directly in launchpadlib without going through the WADL resource.
Changed in launchpad: | |
status: | In Progress → Fix Released |
Gavin Panella (allenap) wrote : | #15 |
Fwiw, rm -r ~/.launchpadlib
William Grant (wgrant) wrote : | #16 |
Huh, indeed. Perhaps there was some WADL cached inappropriately.
Leonard Richardson (leonardr) wrote : | #17 |
The WADL will be cached for a week. I filed bug 714621 to reevaluate our caching strategy in light of our new continuous deployment.
Changed in lazr.restful: | |
status: | Fix Committed → Fix Released |
Martin Pool (mbp) wrote : | #18 |
I had cache problems with this too, much more than a week after this was landed. See bug 752107.
Dave Walker (davewalker) wrote : | #19 |
I am still seeing this issue in current oneiric, using launchpadlib via requestsync.
Thanks.
Martin Pool (mbp) wrote : | #20 |
Dave, can you please post some small example code?
yes, having such a method for recources would be really cool, I'm using something similiar to replace( "api.", "").replace( "beta/" , "")
url = self_url.
very often.