Merge lp:~lifeless/launchpad/edge into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11824
Proposed branch: lp:~lifeless/launchpad/edge
Merge into: lp:launchpad
Diff against target: 158 lines (+9/-91)
3 files modified
lib/canonical/config/schema-lazr.conf (+0/-7)
lib/canonical/launchpad/browser/launchpad.py (+8/-42)
lib/canonical/launchpad/pagetests/webservice/xx-service.txt (+1/-42)
To merge this branch: bzr merge lp:~lifeless/launchpad/edge
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+39594@code.launchpad.net

Commit message

Get rid of stale 'beta redirection' code.

Description of the change

Get rid of stale 'beta redirection' code.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Given we aren't replacing parts of the url any more, we can simplify the following:

   uri = URI(canonical_url(bug.default_bugtask))
   # Empty the traversal stack, since we're redirecting.
   self.request.setTraversalStack([])
   # And perform a temporary redirect.
   return RedirectionView(str(uri), self.request, status=303)

to just be

   # Empty the traversal stack, since we're redirecting.
   self.request.setTraversalStack([])
   # And perform a temporary redirect.
   return RedirectionView(canonical_url(bug.default_bugtask), self.request, status=303)

But on the whole, it looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/config/schema-lazr.conf'
2--- lib/canonical/config/schema-lazr.conf 2010-10-25 13:16:10 +0000
3+++ lib/canonical/config/schema-lazr.conf 2010-10-29 14:12:12 +0000
4@@ -1056,11 +1056,6 @@
5 # datatype: string
6 non_restricted_hostname: launchpad.net
7
8-# If set, the host name to redirect beta testers to.
9-# e.g. beta.launchpad.net
10-# datatype: string
11-beta_testers_redirection_host: none
12-
13 # Domain where incoming email related to specifications are sent to.
14 # datatype: string
15 specs_domain: specs.launchpad.net
16@@ -2008,8 +2003,6 @@
17 openid_delegate_profile: False
18
19 [vhost.api]
20-# This key should be removed once the production configs have been updated.
21-beta_test_team: disabled
22 enable_server_side_representation_cache: False
23 # By default, cache representations for 4 hours.
24 representation_cache_expiration_time: 14400
25
26=== modified file 'lib/canonical/launchpad/browser/launchpad.py'
27--- lib/canonical/launchpad/browser/launchpad.py 2010-10-27 08:51:05 +0000
28+++ lib/canonical/launchpad/browser/launchpad.py 2010-10-29 14:12:12 +0000
29@@ -688,29 +688,12 @@
30 if WebServiceLayer.providedBy(self.request):
31 return None
32
33- mainsite_host = config.vhost.mainsite.hostname
34-
35 # If the hostname for our URL isn't under the main site
36 # (e.g. shipit.ubuntu.com), don't redirect.
37 uri = URI(self.request.getURL())
38- if not uri.host.endswith(mainsite_host):
39+ if not uri.host.endswith(config.vhost.mainsite.hostname):
40 return None
41
42- beta_host = config.launchpad.beta_testers_redirection_host
43- user = getUtility(ILaunchBag).user
44- # Test to see if the user is None before attempting to get the
45- # launchpad_beta_testers celebrity. In the odd test where the
46- # database is empty the series of tests will work.
47- if user is None:
48- user_is_beta_tester = False
49- else:
50- beta_testers = (
51- getUtility(ILaunchpadCelebrities).launchpad_beta_testers)
52- if user.inTeam(beta_testers):
53- user_is_beta_tester = True
54- else:
55- user_is_beta_tester = False
56-
57 # If the request is for a bug then redirect straight to that bug.
58 bug_match = re.match("/bugs/(\d+)$", self.request['PATH_INFO'])
59 if bug_match:
60@@ -722,30 +705,13 @@
61 raise NotFound(self.context, bug_number)
62 if not check_permission("launchpad.View", bug):
63 raise Unauthorized("Bug %s is private" % bug_number)
64- uri = URI(canonical_url(bug.default_bugtask))
65- if beta_host is not None and user_is_beta_tester:
66- # Alter the host name to point at the beta target.
67- new_host = uri.host[:-len(mainsite_host)] + beta_host
68- uri = uri.replace(host=new_host)
69- else:
70- # If no redirection host is set or the user is not a beta tester,
71- # don't redirect.
72- if beta_host is None or not user_is_beta_tester:
73- return None
74- # Alter the host name to point at the beta target.
75- new_host = uri.host[:-len(mainsite_host)] + beta_host
76- uri = uri.replace(host=new_host)
77- # Complete the URL from the environment.
78- uri = uri.replace(path=self.request['PATH_INFO'])
79- query_string = self.request.get('QUERY_STRING')
80- if query_string:
81- uri = uri.replace(query=query_string)
82-
83- # Empty the traversal stack, since we're redirecting.
84- self.request.setTraversalStack([])
85-
86- # And perform a temporary redirect.
87- return RedirectionView(str(uri), self.request, status=303)
88+ # Empty the traversal stack, since we're redirecting.
89+ self.request.setTraversalStack([])
90+ # And perform a temporary redirect.
91+ return RedirectionView(canonical_url(bug.default_bugtask),
92+ self.request, status=303)
93+ # Explicit catchall - do not redirect.
94+ return None
95
96 def publishTraverse(self, request, name):
97 beta_redirection_view = self._getBetaRedirectionView()
98
99=== modified file 'lib/canonical/launchpad/pagetests/webservice/xx-service.txt'
100--- lib/canonical/launchpad/pagetests/webservice/xx-service.txt 2010-10-18 22:24:59 +0000
101+++ lib/canonical/launchpad/pagetests/webservice/xx-service.txt 2010-10-29 14:12:12 +0000
102@@ -30,48 +30,6 @@
103 HTTP/1.1 404 Not Found
104 ...
105
106-No beta team redirection
107-========================
108-
109-Members of the beta team aren't redirected to the beta site on API call.
110-
111-(Enable beta redirection for demonstration purpose)
112-
113- >>> from canonical.config import config
114- >>> beta_data = """
115- ... [launchpad]
116- ... beta_testers_redirection_host = beta.launchpad.dev
117- ... """
118- >>> config.push('beta_data', beta_data)
119-
120- >>> from lp.testing import ANONYMOUS, login, logout
121- >>> from zope.component import getUtility
122- >>> from canonical.launchpad.testing.pages import webservice_for_person
123- >>> from lp.registry.interfaces.person import IPersonSet
124- >>> login(ANONYMOUS)
125- >>> beta_admin = getUtility(IPersonSet).getByEmail(
126- ... 'beta-admin@launchpad.net')
127- >>> beta_user = webservice_for_person(beta_admin)
128- >>> logout()
129-
130-A request to the web site is redirected:
131-
132- >>> print http('GET /~launchpad-beta-owner HTTP/1.1\n'
133- ... 'Host: launchpad.dev\n'
134- ... 'Authorization: Basic %s\n' %
135- ... "beta-admin@launchpad.net:test".encode('base64'))
136- HTTP/1.1 303 See Other
137- ...
138- Location: http://beta.launchpad.dev/~launchpad-beta-owner
139- ...
140-
141-But not a request to the web service:
142-
143- >>> print beta_user.get("/~launchpad-beta-owner")
144- HTTP/1.1 200 Ok
145- ...
146-
147- >>> ignored = config.pop('beta_data')
148
149 Resources not exposed on the web service
150 ========================================
151@@ -118,6 +76,7 @@
152 doesn't recognize the client.
153
154 >>> login(ANONYMOUS)
155+ >>> from zope.component import getUtility
156 >>> consumer_set = getUtility(IOAuthConsumerSet)
157 >>> print consumer_set.getByKey('another-new-consumer')
158 None