Merge lp:~wgrant/launchpad/fix-ajax-subscription-bug-415166 into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/fix-ajax-subscription-bug-415166
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~wgrant/launchpad/fix-ajax-subscription-bug-415166
Reviewer Review Type Date Requested Status
Henning Eggers (community) Approve
Review via email: mp+10297@code.launchpad.net
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

= Summary =

fmt:link and fmt:url were recently changed to always return links to the mainsite for people and pillars. This change broke an untested formatter -- fmt:api_url -- in a way which causes LP.client.links['me'] to be a full webapp URL with domain, instead of the previous path-only URL. This breaks inline bug subscription (bug #415166).

== Proposed fix ==

The change causing problems changed the default value of rootsite from None to 'mainsite' in {Person,Team,Pillar}FormatterAPI.{url,link}. The proposed fix is to change ObjectFormatterAPI.api_url to force a rootsite of None, which causes URLs to be path-only again.

== Pre-implementation notes ==

This was discussed with BjornT and deryck. They agreed with the change as described above.

== Implementation details ==

See above.

== Tests ==

There were previously no tests of fmt:api_url, so I added a new section to lib/canonical/launchpad/doc/tales.txt. This also required modification of a later test in that file to not depend on the order in which factory objects are created.

 $ bin/test -vv -t tales.txt

== Demo and Q/A ==

To Q/A:

 * Log on as any user.
 * Navigate to a bug.
 * Click on 'Subscribe'.
 * Verify that you were subscribed via AJAX.

Revision history for this message
William Grant (wgrant) wrote :

There are still a couple of subscription issues which are separate enough that they don't really belong in this branch. Team unsubscription and incorrect URLs in generated links are bug #415229.

Revision history for this message
Henning Eggers (henninge) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
thanks for fixing this bug which just bit me this morning and I thought
"I ought to file a bug for this." And there you come along with a fix
already. Great!

I also like your fix very much, especially fixing the test to not rely
on (kind of) random numbers is much appreciated.

So, nothing I can find to complain about ;-), this branch is good to land.

 review: approve

Cheers,
Henning
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqKX/gACgkQBT3oW1L17ihcFgCdELSgLqw0uRwR2eprULotwQDJ
OFAAnA8N+1awSiti8o/JkRwbhC6Rpdnx
=1AgZ
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/tales.txt'
2--- lib/canonical/launchpad/doc/tales.txt 2009-08-13 21:32:59 +0000
3+++ lib/canonical/launchpad/doc/tales.txt 2009-08-18 05:00:54 +0000
4@@ -289,6 +289,30 @@
5 >>> login(ANONYMOUS)
6
7
8+The fmt: namespace to get a web service URL
9+-------------------------------------------
10+
11+The `fmt:api_url` expression gives you the absolute API path to an object.
12+This path is everything after the web service version number.
13+
14+ >>> login(ANONYMOUS,
15+ ... LaunchpadTestRequest(SERVER_URL='http://bugs.launchpad.net'))
16+
17+ >>> bob = factory.makePerson(name='bob')
18+ >>> print test_tales("person/fmt:api_url", person=bob)
19+ /~bob
20+
21+ >>> freewidget = factory.makeProduct(name='freewidget')
22+ >>> print test_tales("product/fmt:api_url", product=freewidget)
23+ /freewidget
24+
25+ >>> debuntu = factory.makeProduct(name='debuntu')
26+ >>> print test_tales("distro/fmt:api_url", distro=debuntu)
27+ /debuntu
28+
29+ >>> login(ANONYMOUS)
30+
31+
32 The fmt: namespace to get links
33 -------------------------------
34
35@@ -456,20 +480,22 @@
36 Branch subscriptions show the person and branch name. For users without
37 adequate permissions, a link is not generated.
38
39- >>> branch = factory.makeAnyBranch(title='My Branch')
40- >>> person = factory.makePerson(displayname='My Person')
41+ >>> branch = factory.makeProductBranch(
42+ ... owner=eric, product=fooix, name='my-branch', title='My Branch')
43+ >>> michael = factory.makePerson(
44+ ... name='michael', displayname='Michael the Viking')
45 >>> subscription = factory.makeBranchSubscription(
46- ... branch=branch, person=person)
47+ ... branch=branch, person=michael)
48 >>> test_tales("subscription/fmt:link", subscription=subscription)
49- u'Subscription of My Person to
50- lp://dev/~person-name17/product-name12/branch19'
51+ u'Subscription of Michael the Viking to
52+ lp://dev/~eric/fooix/my-branch'
53
54 But if we log in as the subscriber, a link is presented.
55
56 >>> login_person(subscription.person)
57 >>> test_tales("subscription/fmt:link", subscription=subscription)
58- u'<a href="http://.../+subscription/person-name21">Subscription
59- of My Person to lp://dev/~person-name17/product-name12/branch19</a>'
60+ u'<a href="http://.../+subscription/michael">Subscription
61+ of Michael the Viking to lp://dev/~eric/fooix/my-branch</a>'
62
63 Merge proposals also have a link formatter, which displays branch
64 titles:
65
66=== modified file 'lib/canonical/launchpad/webapp/tales.py'
67--- lib/canonical/launchpad/webapp/tales.py 2009-08-14 12:56:19 +0000
68+++ lib/canonical/launchpad/webapp/tales.py 2009-08-18 05:03:00 +0000
69@@ -455,7 +455,10 @@
70 version number. It's the same as 'url', but without any view
71 name.
72 """
73- return self.url()
74+
75+ # Some classes override the rootsite. We always want a path-only
76+ # URL, so we override it to nothing.
77+ return self.url(rootsite=None)
78
79 def traverse(self, name, furtherPath):
80 if name.startswith('link:') or name.startswith('url:'):