Merge lp:~salgado/launchpad/edge-redirect-bugs into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/edge-redirect-bugs
Merge into: lp:launchpad
Diff against target: 228 lines (+59/-47)
7 files modified
lib/canonical/launchpad/doc/timeout.txt (+1/-1)
lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt (+7/-6)
lib/canonical/launchpad/templates/launchpad-requestexpired.pt (+9/-20)
lib/canonical/launchpad/templates/oops.pt (+24/-0)
lib/canonical/launchpad/webapp/error.py (+3/-3)
lib/lp/app/stories/basics/xx-beta-testers-redirection.txt (+7/-7)
lib/lp/app/templates/base-layout-macros.pt (+8/-10)
To merge this branch: bzr merge lp:~salgado/launchpad/edge-redirect-bugs
Reviewer Review Type Date Requested Status
Gavin Panella (community) code Approve
Review via email: mp+21054@code.launchpad.net

Description of the change

This branch fixes bug 403863, bug 512295 and bug 528184.

I've changed lib/lp/app/templates/base-layout-macros.pt to always show
the enable/disable redirect link when is_edge is True.

In oops.pt I added a notification message (together with a button to
disable redirects) when we're on edge. Also had to include lp.js, for
the JS function that actually disables redirection (setBetaRedirect).
Need to do all this here because oops.pt doesn't use our main template.

And in launchpad-requestexpired.pt I replaced the JS that would show a
hidden (display:none) div when it was seen on edge with a tal:condition
around that div. However, thanks to the change to base-layout-macros.pt
above, the timeout page now has one link to disable redirection at the
bottom and one button for the same purpose at the top. I think we
should remove the notification and leave just the link at the bottom.

== Demo and Q/A ==

First, set is_edge to true on configs/schema-lazr.conf.

To see the new notification on the OOPS page you need to manually edit a
template so that it crashes when rendering and load a page that uses
that template. This will cause an OOPS and you should see the
notification.

To see it on the timeout page, set db_statement_timeout to 1 in
configs/schema-lazr.conf and open any page.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/templates/oops.pt
  lib/canonical/launchpad/webapp/error.py
  lib/canonical/launchpad/doc/timeout.txt
  lib/lp/app/templates/base-layout-macros.pt
  lib/canonical/launchpad/templates/launchpad-requestexpired.pt
  lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt
  lib/lp/app/stories/basics/xx-beta-testers-redirection.txt

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :
Download full text (10.1 KiB)

Hi,

The "Disable edge redirect" message is only shown when is_edge is true
*and* site_message is set. The cover letter didn't mention that, but I
assume that's fine.

I have a few comments, but nothing terrible :)

Gavin.

> === modified file 'lib/canonical/launchpad/doc/timeout.txt'
> --- lib/canonical/launchpad/doc/timeout.txt 2008-05-17 02:36:00 +0000
> +++ lib/canonical/launchpad/doc/timeout.txt 2010-03-10 16:32:41 +0000
> @@ -12,7 +12,7 @@
> >>> from canonical.lazr.timeout import get_default_timeout_function
> >>> from canonical.launchpad.webapp.servers import (
> ... set_launchpad_default_timeout)
> - >>> old_func = get_default_timeout_function()
> + >>> old_func = get_default_timeout_function()
>
> >>> from zope.app.appsetup import ProcessStarting
>
>
> === modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
> --- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-02-09 17:25:13 +0000
> +++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-03-10 16:32:41 +0000
> @@ -103,16 +103,18 @@
> ... 'a', onclick="setBetaRedirect(false)"))
> Disable edge redirect.
>
> -The disable-redirect link will not appear in the site_message when
> -browsed by non-beta users.
> +The disable-redirect link will also appear in the site_message when browsed by
> +non-beta/anonymous users. This is to reduce the annoyance when users are
> +logged into launchpad.net but haven't noticed yet that they need to log into
> +edge as well (https://launchpad.net/bugs/160191).
>
> >>> browser.open('http://launchpad.dev/ubuntu')
> >>> print extract_text(find_tags_by_class(
> ... browser.contents, 'sitemessage')[0])
> - This is a beta site.
> + This is a beta site. Disable edge redirect.
>
> -Similarly, once the redirection has been inhibited, the link changes to
> -enable redirects..
> +Once the redirection has been inhibited, the link changes to enable
> +redirects.
>
> # Workaround bug in mechanize where you cannot use the Cookie
> # header with the CookieJar
> @@ -135,7 +137,6 @@
> ... 'a', onclick="setBetaRedirect(true)"))
> Enable edge redirect.
>
> -
> # Remove the specific site-message config data before continuing.
> >>> dummy = config.pop('edge_config_data')
>
>
> === modified file 'lib/canonical/launchpad/templates/launchpad-requestexpired.pt'
> --- lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2009-07-28 17:19:42 +0000
> +++ lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2010-03-10 16:32:41 +0000
> @@ -9,27 +9,16 @@
> <body>
> <div class="top-portlet" metal:fill-slot="main">
> <h1 class="exception">Timeout error</h1>
> - <div
> - id="redirect_notice" style="display:none" class="informational message">
> - <p>Our edge server has a lower timeout threshold than launchpad.net,
> - so we can catch those before they hit a wider audience.
> - As a member of the Launchpad Beta Testers team, you're more
> - likely to experience them. If this is blocking your work, you
> - can disable redirection.</p>
> - <...

review: Approve (code)
Revision history for this message
Guilherme Salgado (salgado) wrote :
Download full text (5.5 KiB)

On Wed, 2010-03-10 at 17:06 +0000, Gavin Panella wrote:
> Review: Approve code
> Hi,
>
> The "Disable edge redirect" message is only shown when is_edge is true
> *and* site_message is set. The cover letter didn't mention that, but I
> assume that's fine.

Indeed, I forgot to mention that.

Thanks for the review!

>
> I have a few comments, but nothing terrible :)
>

> > === modified file 'lib/canonical/launchpad/templates/launchpad-requestexpired.pt'
> > --- lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2009-07-28 17:19:42 +0000
> > +++ lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2010-03-10 16:32:41 +0000
> > @@ -9,27 +9,16 @@
> > <body>
> > <div class="top-portlet" metal:fill-slot="main">
> > <h1 class="exception">Timeout error</h1>
> > - <div
> > - id="redirect_notice" style="display:none" class="informational message">
> > - <p>Our edge server has a lower timeout threshold than launchpad.net,
> > - so we can catch those before they hit a wider audience.
> > - As a member of the Launchpad Beta Testers team, you're more
> > - likely to experience them. If this is blocking your work, you
> > - can disable redirection.</p>
> > - <p><button onclick="setBetaRedirect(false)">Disable redirection
> > - for 2 hours</button></p>
> > + <div tal:condition="is_edge"
> > + id="redirect_notice" class="informational message">
> > + <p>Our edge server has a lower timeout threshold than launchpad.net,
> > + so we can catch those before they hit a wider audience.
> > + As a member of the Launchpad Beta Testers team, you're more
>
> You haven't changed it, but this isn't strictly true - that the viewer
> is a beta tester - any more is it? Doesn't matter much though.

You're right. How about this:

  <p>Our edge server has a lower timeout threshold than launchpad.net,
  so we can catch those before they hit a wider audience.
  If this is blocking your work, you can disable automatic redirection
  to edge in order to use launchpad.net.</p>
?

>
> > + likely to experience them. If this is blocking your work, you
> > + can disable redirection.</p>
> > + <p><button onclick="setBetaRedirect(false)">Disable redirection
> > + for 2 hours</button></p>
> > </div>
> > - <script type="text/javascript">
> > - var edge_cookie = document.cookie.match('edge');
> > - var edge_host = document.location.hostname.match('edge');
> > -
> > - // Logic has been inverted in the next line to avoid breaking
> > - // XHTML compliance of the template due to ampersand usage.
> > - if (!(edge_cookie || edge_host)) {
> > - redirect_notice_div = document.getElementById('redirect_notice');
> > - redirect_notice_div.style.display = "block";
> > - };
> > - </script>
> > <p>
> > Sorry, something just went wrong in Launchpad.
> > </p>
> >
> > === modified file 'lib/canonical/launchpad/templates/oops.pt'
> > --- lib/canonical/launchpad/templates/oops.pt 2010-01-13 17:58:30 +0000
> > +++ lib/canonical/launchpad/te...

Read more...

Revision history for this message
Guilherme Salgado (salgado) wrote :

On Wed, 2010-03-10 at 14:42 -0300, Guilherme Salgado wrote:
> > > === modified file 'lib/canonical/launchpad/templates/launchpad-requestexpired.pt'
> > > --- lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2009-07-28 17:19:42 +0000
> > > +++ lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2010-03-10 16:32:41 +0000
> > > @@ -9,27 +9,16 @@
> > > <body>
> > > <div class="top-portlet" metal:fill-slot="main">
> > > <h1 class="exception">Timeout error</h1>
> > > - <div
> > > - id="redirect_notice" style="display:none" class="informational message">
> > > - <p>Our edge server has a lower timeout threshold than launchpad.net,
> > > - so we can catch those before they hit a wider audience.
> > > - As a member of the Launchpad Beta Testers team, you're more
> > > - likely to experience them. If this is blocking your work, you
> > > - can disable redirection.</p>
> > > - <p><button onclick="setBetaRedirect(false)">Disable redirection
> > > - for 2 hours</button></p>
> > > + <div tal:condition="is_edge"
> > > + id="redirect_notice" class="informational message">
> > > + <p>Our edge server has a lower timeout threshold than launchpad.net,
> > > + so we can catch those before they hit a wider audience.
> > > + As a member of the Launchpad Beta Testers team, you're more
> >
> > You haven't changed it, but this isn't strictly true - that the viewer
> > is a beta tester - any more is it? Doesn't matter much though.
>
> You're right. How about this:
>
> <p>Our edge server has a lower timeout threshold than launchpad.net,
> so we can catch those before they hit a wider audience.
> If this is blocking your work, you can disable automatic redirection
> to edge in order to use launchpad.net.</p>
> ?

Or maybe

    If this is blocking your work and you are a member of the Launchpad
    Beta Testers team, you can disable automatic redirection
    to edge in order to use launchpad.net.</p>

Revision history for this message
Gavin Panella (allenap) wrote :

I think that reads well, and the second version is better. It might
be nice if "disable automatic redirection" in the paragraph was also
clickable, but I suspect that enough work has been done on this
already.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/doc/timeout.txt'
--- lib/canonical/launchpad/doc/timeout.txt 2008-05-17 02:36:00 +0000
+++ lib/canonical/launchpad/doc/timeout.txt 2010-03-10 19:12:31 +0000
@@ -12,7 +12,7 @@
12 >>> from canonical.lazr.timeout import get_default_timeout_function12 >>> from canonical.lazr.timeout import get_default_timeout_function
13 >>> from canonical.launchpad.webapp.servers import (13 >>> from canonical.launchpad.webapp.servers import (
14 ... set_launchpad_default_timeout)14 ... set_launchpad_default_timeout)
15 >>> old_func = get_default_timeout_function()15 >>> old_func = get_default_timeout_function()
1616
17 >>> from zope.app.appsetup import ProcessStarting17 >>> from zope.app.appsetup import ProcessStarting
1818
1919
=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-02-09 17:25:13 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-03-10 19:12:31 +0000
@@ -103,16 +103,18 @@
103 ... 'a', onclick="setBetaRedirect(false)"))103 ... 'a', onclick="setBetaRedirect(false)"))
104 Disable edge redirect.104 Disable edge redirect.
105105
106The disable-redirect link will not appear in the site_message when106The disable-redirect link will also appear in the site_message when browsed by
107browsed by non-beta users.107non-beta/anonymous users. This is to reduce the annoyance when users are
108logged into launchpad.net but haven't noticed yet that they need to log into
109edge as well (https://launchpad.net/bugs/160191).
108110
109 >>> browser.open('http://launchpad.dev/ubuntu')111 >>> browser.open('http://launchpad.dev/ubuntu')
110 >>> print extract_text(find_tags_by_class(112 >>> print extract_text(find_tags_by_class(
111 ... browser.contents, 'sitemessage')[0])113 ... browser.contents, 'sitemessage')[0])
112 This is a beta site.114 This is a beta site. Disable edge redirect.
113115
114Similarly, once the redirection has been inhibited, the link changes to116Once the redirection has been inhibited, the link changes to enable
115enable redirects..117redirects.
116118
117 # Workaround bug in mechanize where you cannot use the Cookie119 # Workaround bug in mechanize where you cannot use the Cookie
118 # header with the CookieJar120 # header with the CookieJar
@@ -135,7 +137,6 @@
135 ... 'a', onclick="setBetaRedirect(true)"))137 ... 'a', onclick="setBetaRedirect(true)"))
136 Enable edge redirect.138 Enable edge redirect.
137139
138
139 # Remove the specific site-message config data before continuing.140 # Remove the specific site-message config data before continuing.
140 >>> dummy = config.pop('edge_config_data')141 >>> dummy = config.pop('edge_config_data')
141142
142143
=== modified file 'lib/canonical/launchpad/templates/launchpad-requestexpired.pt'
--- lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2009-07-28 17:19:42 +0000
+++ lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2010-03-10 19:12:31 +0000
@@ -9,27 +9,16 @@
9 <body>9 <body>
10 <div class="top-portlet" metal:fill-slot="main">10 <div class="top-portlet" metal:fill-slot="main">
11 <h1 class="exception">Timeout error</h1>11 <h1 class="exception">Timeout error</h1>
12 <div12 <div tal:condition="is_edge"
13 id="redirect_notice" style="display:none" class="informational message">13 id="redirect_notice" class="informational message">
14 <p>Our edge server has a lower timeout threshold than launchpad.net,14 <p>Our edge server has a lower timeout threshold than launchpad.net,
15 so we can catch those before they hit a wider audience.15 so we can catch those before they hit a wider audience.
16 As a member of the Launchpad Beta Testers team, you're more16 If this is blocking your work and you are a member of the Launchpad
17 likely to experience them. If this is blocking your work, you17 Beta Testers team, you can disable automatic redirection
18 can disable redirection.</p>18 to edge in order to use launchpad.net.</p>
19 <p><button onclick="setBetaRedirect(false)">Disable redirection19 <p><button onclick="setBetaRedirect(false)">Disable redirection
20 for 2 hours</button></p>20 for 2 hours</button></p>
21 </div>21 </div>
22 <script type="text/javascript">
23 var edge_cookie = document.cookie.match('edge');
24 var edge_host = document.location.hostname.match('edge');
25
26 // Logic has been inverted in the next line to avoid breaking
27 // XHTML compliance of the template due to ampersand usage.
28 if (!(edge_cookie || edge_host)) {
29 redirect_notice_div = document.getElementById('redirect_notice');
30 redirect_notice_div.style.display = "block";
31 };
32 </script>
33 <p>22 <p>
34 Sorry, something just went wrong in Launchpad.23 Sorry, something just went wrong in Launchpad.
35 </p>24 </p>
3625
=== modified file 'lib/canonical/launchpad/templates/oops.pt'
--- lib/canonical/launchpad/templates/oops.pt 2010-01-13 17:58:30 +0000
+++ lib/canonical/launchpad/templates/oops.pt 2010-03-10 19:12:31 +0000
@@ -9,6 +9,9 @@
9 <style type="text/css" media="screen, print">9 <style type="text/css" media="screen, print">
10 @import url(/+icing/rev5/combo.css);10 @import url(/+icing/rev5/combo.css);
11 </style>11 </style>
12 <script type="text/javascript"
13 tal:content="string:var cookie_scope = '${request/lp:cookie_scope}';"></script>
14 <script type="text/javascript" src="/+icing/rev5/build/lp/lp.js" />
12 </head>15 </head>
13 <body>16 <body>
14 <div class="yui-d0">17 <div class="yui-d0">
@@ -27,6 +30,27 @@
27 (Error <abbr>ID</abbr>:30 (Error <abbr>ID</abbr>:
28 <tal:oops replace="structure view/oops_id_text" />)31 <tal:oops replace="structure view/oops_id_text" />)
29 </p>32 </p>
33
34 <div id="redirect_notice" style="display:none"
35 class="informational message">
36 <p>This server runs pre-release code, so it's possible this problem
37 doesn't affect launchpad.net. If you're a member of the Launchpad
38 Beta Testers team, you can disable redirection in order to use
39 launchpad.net.</p>
40 <p><button onclick="setBetaRedirect(false)">Disable redirection
41 for 2 hours</button></p>
42 </div>
43 <tal:comment condition="nothing">
44 Can't use the 'is_edge' global because we don't use our page
45 macros here.
46 </tal:comment>
47 <script type="text/javascript">
48 if (document.location.hostname.match('edge.')) {
49 redirect_notice_div = document.getElementById('redirect_notice');
50 redirect_notice_div.style.display = "block";
51 };
52 </script>
53
30 <tal:traceback replace="structure view/maybeShowTraceback" />54 <tal:traceback replace="structure view/maybeShowTraceback" />
3155
32 <div class="related">56 <div class="related">
3357
=== modified file 'lib/canonical/launchpad/webapp/error.py'
--- lib/canonical/launchpad/webapp/error.py 2009-12-23 16:17:12 +0000
+++ lib/canonical/launchpad/webapp/error.py 2010-03-10 19:12:31 +0000
@@ -26,12 +26,13 @@
26from canonical.cachedproperty import cachedproperty26from canonical.cachedproperty import cachedproperty
27from canonical.config import config27from canonical.config import config
28import canonical.launchpad.layers28import canonical.launchpad.layers
29from canonical.launchpad.webapp.publisher import LaunchpadView
29from canonical.launchpad.webapp.adapter import (30from canonical.launchpad.webapp.adapter import (
30 clear_request_started, set_request_started)31 clear_request_started, set_request_started)
31from canonical.launchpad.webapp.interfaces import ILaunchBag32from canonical.launchpad.webapp.interfaces import ILaunchBag
3233
3334
34class SystemErrorView:35class SystemErrorView(LaunchpadView):
35 """Helper class for views on exceptions.36 """Helper class for views on exceptions.
3637
37 Also, sets a 500 response code.38 Also, sets a 500 response code.
@@ -64,8 +65,7 @@
64 safe_to_show_in_restricted_mode = False65 safe_to_show_in_restricted_mode = False
6566
66 def __init__(self, context, request):67 def __init__(self, context, request):
67 self.context = context68 super(SystemErrorView, self).__init__(context, request)
68 self.request = request
69 self.request.response.removeAllNotifications()69 self.request.response.removeAllNotifications()
70 if self.response_code is not None:70 if self.response_code is not None:
71 self.request.response.setStatus(self.response_code)71 self.request.response.setStatus(self.response_code)
7272
=== modified file 'lib/lp/app/stories/basics/xx-beta-testers-redirection.txt'
--- lib/lp/app/stories/basics/xx-beta-testers-redirection.txt 2010-02-09 17:25:13 +0000
+++ lib/lp/app/stories/basics/xx-beta-testers-redirection.txt 2010-03-10 19:12:31 +0000
@@ -216,11 +216,12 @@
216216
217 >>> logout()217 >>> logout()
218218
219Decrease the timeout values for launchpad.dev219Decrease the timeout values for launchpad.dev and pretend we're on the edge
220server.
220221
221 >>> beta_data = """222 >>> beta_data = """
222 ... [launchpad]223 ... [launchpad]
223 ... beta_testers_redirection_host = edge.launchpad.dev224 ... is_edge: True
224 ... [database]225 ... [database]
225 ... db_statement_timeout: 1226 ... db_statement_timeout: 1
226 ... soft_request_timeout: 2227 ... soft_request_timeout: 2
@@ -240,15 +241,14 @@
240 <title>Error: Timeout</title>241 <title>Error: Timeout</title>
241 ...242 ...
242 <h1 class="exception">Timeout error</h1>243 <h1 class="exception">Timeout error</h1>
243 <div id="redirect_notice" style="display:none" class="informational message">244 ...
244 <p>Our edge server has a lower timeout threshold than launchpad.net,245 <p>Our edge server has a lower timeout threshold than launchpad.net,
245 so we can catch those before they hit a wider audience.246 so we can catch those before they hit a wider audience.
246 As a member of the Launchpad Beta Testers team, you're more247 If this is blocking your work and you are a member of the Launchpad
247 likely to experience them. If this is blocking your work, you248 Beta Testers team, you can disable automatic redirection
248 can disable redirection.</p>249 to edge in order to use launchpad.net.</p>
249 <p><button onclick="setBetaRedirect(false)">Disable redirection250 <p><button onclick="setBetaRedirect(false)">Disable redirection
250 for 2 hours</button></p>251 for 2 hours</button></p>
251 </div>
252 ...252 ...
253253
254Restore the config to state it was in at the start of the test.254Restore the config to state it was in at the start of the test.
255255
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2010-03-05 02:57:25 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2010-03-10 19:12:31 +0000
@@ -379,16 +379,14 @@
379 This site is running pre-release code.379 This site is running pre-release code.
380 </tal:site_message>380 </tal:site_message>
381 <tal:edge_only condition="is_edge">381 <tal:edge_only condition="is_edge">
382 <tal:beta_user condition="view/macro:isbetauser">382 <a href="#" class="js-action" onclick="setBetaRedirect(false)"
383 <a href="#" class="js-action" onclick="setBetaRedirect(false)"383 tal:condition="not:view/isRedirectInhibited">
384 tal:condition="not:view/isRedirectInhibited">384 Disable edge redirect.
385 Disable edge redirect.385 </a>
386 </a>386 <a href="#" class="js-action" onclick="setBetaRedirect(true)"
387 <a href="#" class="js-action" onclick="setBetaRedirect(true)"387 tal:condition="view/isRedirectInhibited">
388 tal:condition="view/isRedirectInhibited">388 Enable edge redirect.
389 Enable edge redirect.389 </a>
390 </a>
391 </tal:beta_user>
392 </tal:edge_only>390 </tal:edge_only>
393 </div>391 </div>
394</metal:site-message>392</metal:site-message>