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
1=== modified file 'lib/canonical/launchpad/doc/timeout.txt'
2--- lib/canonical/launchpad/doc/timeout.txt 2008-05-17 02:36:00 +0000
3+++ lib/canonical/launchpad/doc/timeout.txt 2010-03-10 19:12:31 +0000
4@@ -12,7 +12,7 @@
5 >>> from canonical.lazr.timeout import get_default_timeout_function
6 >>> from canonical.launchpad.webapp.servers import (
7 ... set_launchpad_default_timeout)
8- >>> old_func = get_default_timeout_function()
9+ >>> old_func = get_default_timeout_function()
10
11 >>> from zope.app.appsetup import ProcessStarting
12
13
14=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
15--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-02-09 17:25:13 +0000
16+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2010-03-10 19:12:31 +0000
17@@ -103,16 +103,18 @@
18 ... 'a', onclick="setBetaRedirect(false)"))
19 Disable edge redirect.
20
21-The disable-redirect link will not appear in the site_message when
22-browsed by non-beta users.
23+The disable-redirect link will also appear in the site_message when browsed by
24+non-beta/anonymous users. This is to reduce the annoyance when users are
25+logged into launchpad.net but haven't noticed yet that they need to log into
26+edge as well (https://launchpad.net/bugs/160191).
27
28 >>> browser.open('http://launchpad.dev/ubuntu')
29 >>> print extract_text(find_tags_by_class(
30 ... browser.contents, 'sitemessage')[0])
31- This is a beta site.
32+ This is a beta site. Disable edge redirect.
33
34-Similarly, once the redirection has been inhibited, the link changes to
35-enable redirects..
36+Once the redirection has been inhibited, the link changes to enable
37+redirects.
38
39 # Workaround bug in mechanize where you cannot use the Cookie
40 # header with the CookieJar
41@@ -135,7 +137,6 @@
42 ... 'a', onclick="setBetaRedirect(true)"))
43 Enable edge redirect.
44
45-
46 # Remove the specific site-message config data before continuing.
47 >>> dummy = config.pop('edge_config_data')
48
49
50=== modified file 'lib/canonical/launchpad/templates/launchpad-requestexpired.pt'
51--- lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2009-07-28 17:19:42 +0000
52+++ lib/canonical/launchpad/templates/launchpad-requestexpired.pt 2010-03-10 19:12:31 +0000
53@@ -9,27 +9,16 @@
54 <body>
55 <div class="top-portlet" metal:fill-slot="main">
56 <h1 class="exception">Timeout error</h1>
57- <div
58- id="redirect_notice" style="display:none" class="informational message">
59- <p>Our edge server has a lower timeout threshold than launchpad.net,
60- so we can catch those before they hit a wider audience.
61- As a member of the Launchpad Beta Testers team, you're more
62- likely to experience them. If this is blocking your work, you
63- can disable redirection.</p>
64- <p><button onclick="setBetaRedirect(false)">Disable redirection
65- for 2 hours</button></p>
66+ <div tal:condition="is_edge"
67+ id="redirect_notice" class="informational message">
68+ <p>Our edge server has a lower timeout threshold than launchpad.net,
69+ so we can catch those before they hit a wider audience.
70+ If this is blocking your work and you are a member of the Launchpad
71+ Beta Testers team, you can disable automatic redirection
72+ to edge in order to use launchpad.net.</p>
73+ <p><button onclick="setBetaRedirect(false)">Disable redirection
74+ for 2 hours</button></p>
75 </div>
76- <script type="text/javascript">
77- var edge_cookie = document.cookie.match('edge');
78- var edge_host = document.location.hostname.match('edge');
79-
80- // Logic has been inverted in the next line to avoid breaking
81- // XHTML compliance of the template due to ampersand usage.
82- if (!(edge_cookie || edge_host)) {
83- redirect_notice_div = document.getElementById('redirect_notice');
84- redirect_notice_div.style.display = "block";
85- };
86- </script>
87 <p>
88 Sorry, something just went wrong in Launchpad.
89 </p>
90
91=== modified file 'lib/canonical/launchpad/templates/oops.pt'
92--- lib/canonical/launchpad/templates/oops.pt 2010-01-13 17:58:30 +0000
93+++ lib/canonical/launchpad/templates/oops.pt 2010-03-10 19:12:31 +0000
94@@ -9,6 +9,9 @@
95 <style type="text/css" media="screen, print">
96 @import url(/+icing/rev5/combo.css);
97 </style>
98+ <script type="text/javascript"
99+ tal:content="string:var cookie_scope = '${request/lp:cookie_scope}';"></script>
100+ <script type="text/javascript" src="/+icing/rev5/build/lp/lp.js" />
101 </head>
102 <body>
103 <div class="yui-d0">
104@@ -27,6 +30,27 @@
105 (Error <abbr>ID</abbr>:
106 <tal:oops replace="structure view/oops_id_text" />)
107 </p>
108+
109+ <div id="redirect_notice" style="display:none"
110+ class="informational message">
111+ <p>This server runs pre-release code, so it's possible this problem
112+ doesn't affect launchpad.net. If you're a member of the Launchpad
113+ Beta Testers team, you can disable redirection in order to use
114+ launchpad.net.</p>
115+ <p><button onclick="setBetaRedirect(false)">Disable redirection
116+ for 2 hours</button></p>
117+ </div>
118+ <tal:comment condition="nothing">
119+ Can't use the 'is_edge' global because we don't use our page
120+ macros here.
121+ </tal:comment>
122+ <script type="text/javascript">
123+ if (document.location.hostname.match('edge.')) {
124+ redirect_notice_div = document.getElementById('redirect_notice');
125+ redirect_notice_div.style.display = "block";
126+ };
127+ </script>
128+
129 <tal:traceback replace="structure view/maybeShowTraceback" />
130
131 <div class="related">
132
133=== modified file 'lib/canonical/launchpad/webapp/error.py'
134--- lib/canonical/launchpad/webapp/error.py 2009-12-23 16:17:12 +0000
135+++ lib/canonical/launchpad/webapp/error.py 2010-03-10 19:12:31 +0000
136@@ -26,12 +26,13 @@
137 from canonical.cachedproperty import cachedproperty
138 from canonical.config import config
139 import canonical.launchpad.layers
140+from canonical.launchpad.webapp.publisher import LaunchpadView
141 from canonical.launchpad.webapp.adapter import (
142 clear_request_started, set_request_started)
143 from canonical.launchpad.webapp.interfaces import ILaunchBag
144
145
146-class SystemErrorView:
147+class SystemErrorView(LaunchpadView):
148 """Helper class for views on exceptions.
149
150 Also, sets a 500 response code.
151@@ -64,8 +65,7 @@
152 safe_to_show_in_restricted_mode = False
153
154 def __init__(self, context, request):
155- self.context = context
156- self.request = request
157+ super(SystemErrorView, self).__init__(context, request)
158 self.request.response.removeAllNotifications()
159 if self.response_code is not None:
160 self.request.response.setStatus(self.response_code)
161
162=== modified file 'lib/lp/app/stories/basics/xx-beta-testers-redirection.txt'
163--- lib/lp/app/stories/basics/xx-beta-testers-redirection.txt 2010-02-09 17:25:13 +0000
164+++ lib/lp/app/stories/basics/xx-beta-testers-redirection.txt 2010-03-10 19:12:31 +0000
165@@ -216,11 +216,12 @@
166
167 >>> logout()
168
169-Decrease the timeout values for launchpad.dev
170+Decrease the timeout values for launchpad.dev and pretend we're on the edge
171+server.
172
173 >>> beta_data = """
174 ... [launchpad]
175- ... beta_testers_redirection_host = edge.launchpad.dev
176+ ... is_edge: True
177 ... [database]
178 ... db_statement_timeout: 1
179 ... soft_request_timeout: 2
180@@ -240,15 +241,14 @@
181 <title>Error: Timeout</title>
182 ...
183 <h1 class="exception">Timeout error</h1>
184- <div id="redirect_notice" style="display:none" class="informational message">
185+ ...
186 <p>Our edge server has a lower timeout threshold than launchpad.net,
187 so we can catch those before they hit a wider audience.
188- As a member of the Launchpad Beta Testers team, you're more
189- likely to experience them. If this is blocking your work, you
190- can disable redirection.</p>
191+ If this is blocking your work and you are a member of the Launchpad
192+ Beta Testers team, you can disable automatic redirection
193+ to edge in order to use launchpad.net.</p>
194 <p><button onclick="setBetaRedirect(false)">Disable redirection
195 for 2 hours</button></p>
196- </div>
197 ...
198
199 Restore the config to state it was in at the start of the test.
200
201=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
202--- lib/lp/app/templates/base-layout-macros.pt 2010-03-05 02:57:25 +0000
203+++ lib/lp/app/templates/base-layout-macros.pt 2010-03-10 19:12:31 +0000
204@@ -379,16 +379,14 @@
205 This site is running pre-release code.
206 </tal:site_message>
207 <tal:edge_only condition="is_edge">
208- <tal:beta_user condition="view/macro:isbetauser">
209- <a href="#" class="js-action" onclick="setBetaRedirect(false)"
210- tal:condition="not:view/isRedirectInhibited">
211- Disable edge redirect.
212- </a>
213- <a href="#" class="js-action" onclick="setBetaRedirect(true)"
214- tal:condition="view/isRedirectInhibited">
215- Enable edge redirect.
216- </a>
217- </tal:beta_user>
218+ <a href="#" class="js-action" onclick="setBetaRedirect(false)"
219+ tal:condition="not:view/isRedirectInhibited">
220+ Disable edge redirect.
221+ </a>
222+ <a href="#" class="js-action" onclick="setBetaRedirect(true)"
223+ tal:condition="view/isRedirectInhibited">
224+ Enable edge redirect.
225+ </a>
226 </tal:edge_only>
227 </div>
228 </metal:site-message>