Merge lp://staging/~jtv/launchpad/bug-632880 into lp://staging/launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11526
Proposed branch: lp://staging/~jtv/launchpad/bug-632880
Merge into: lp://staging/launchpad
Diff against target: 622 lines (+223/-111)
6 files modified
lib/canonical/launchpad/database/librarian.py (+1/-1)
lib/canonical/librarian/client.py (+120/-58)
lib/canonical/librarian/ftests/test_web.py (+35/-29)
lib/canonical/librarian/interfaces.py (+9/-0)
lib/lp/testing/fakelibrarian.py (+7/-2)
lib/lp/testing/tests/test_fakelibrarian.py (+51/-21)
To merge this branch: bzr merge lp://staging/~jtv/launchpad/bug-632880
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code* Abstain
Robert Collins (community) Approve
Review via email: mp+34961@code.staging.launchpad.net

Commit message

Generate URLs straight from LibraryFileAlias.

Description of the change

= Bug 632880 =

This fixes a small and subtle problem in working with the Librarian. When we render links to persons, products, and so on, we include any icons that may have been set for them. The link formatter gets the LibraryFileAlias for each icon, and gets its URL.

Under the hood, the LibraryFileAlias delegates this work to the LibrarianDownloadClient. But instead of a reference to the LibraryFileAlias, it only passes an id. The LibrarianDownloadClient then looks up the same LibraryFileAlias in the database. This isn't so costly, except when the request is running off the master store and the LibraryFileAlias was retrieved from the slave store. In that case, all icon LibraryFileAliases get requested again. This is a waste.

In this branch I make retrieval of URLs work directly from the LibraryFileAlias object. This would be bad if there were a thread or process boundary between the point where the LibraryFileAlias is retrieved and where it's used, but that is not the case here.

A lot of the work is actually in making sure that the FakeLibrarian supports the new method, and that it stays equivalent to the one in the real Librarian.

To test:
{{{
./bin/test -vvc canonical.librarian.ftests.test_web
./bin/test -vvc lp.testing.tests.test_fakelibrarian
}}}

There's plenty of lint, I'm sorry to say, though none that I introduced. I'ld be happy to clean it up, but did not want to pollute the diff for the review.

Jeroen

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

A conflicting change came in after I put this up for review. It added a fair amount of lint, which I hope I've mostly cleaned up. Unfortunately the combination with my refactorings makes the diff hard to read: I extracted a few clear units of functionality into their own methods, but the diff tends to show this as a renamed method with confusing changes.

Revision history for this message
Robert Collins (lifeless) wrote :

heh, the conflicting change was in db-devel already :P

Revision history for this message
Robert Collins (lifeless) wrote :

Looks like compose_url isn't intended to be public, perhaps _compose_url.

review: Approve
Revision history for this message
Steve Kowalik (stevenk) wrote :

Robert has stolen my review!

review: Abstain (code*)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.