Merge lp:~cjwatson/launchpad/remove-webservice-get-commit into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18535
Proposed branch: lp:~cjwatson/launchpad/remove-webservice-get-commit
Merge into: lp:launchpad
Diff against target: 141 lines (+7/-53)
2 files modified
lib/lp/services/webapp/servers.py (+2/-25)
lib/lp/services/webapp/tests/test_servers.py (+5/-28)
To merge this branch: bzr merge lp:~cjwatson/launchpad/remove-webservice-get-commit
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+336604@code.launchpad.net

Commit message

Remove the post-webservice-GET commit.

Description of the change

It's been disabled for everyone since 2018-01-02 with no reported ill effects, so it's time for it to go.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/webapp/servers.py'
2--- lib/lp/services/webapp/servers.py 2017-12-17 00:56:02 +0000
3+++ lib/lp/services/webapp/servers.py 2018-01-25 13:17:27 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Definition of the internet servers that Launchpad uses."""
10@@ -31,7 +31,6 @@
11 from zope.app.server import wsgi
12 from zope.app.wsgi import WSGIPublisherApplication
13 from zope.component import getUtility
14-from zope.event import notify
15 from zope.formlib.itemswidgets import MultiDataHelper
16 from zope.formlib.widget import SimpleInputWidget
17 from zope.interface import (
18@@ -64,10 +63,7 @@
19 from lp.app.errors import UnexpectedFormData
20 import lp.layers
21 from lp.services.config import config
22-from lp.services.features import (
23- get_relevant_feature_controller,
24- getFeatureFlag,
25- )
26+from lp.services.features import get_relevant_feature_controller
27 from lp.services.features.flags import NullFeatureController
28 from lp.services.feeds.interfaces.application import IFeedsApplication
29 from lp.services.feeds.interfaces.feed import IFeed
30@@ -87,7 +83,6 @@
31 )
32 from lp.services.webapp.errorlog import ErrorReportRequest
33 from lp.services.webapp.interfaces import (
34- FinishReadOnlyRequestEvent,
35 IBasicLaunchpadRequest,
36 IBrowserFormNG,
37 IFavicon,
38@@ -1241,24 +1236,6 @@
39 else:
40 return super(WebServicePublication, self).getResource(request, ob)
41
42- def finishReadOnlyRequest(self, request, ob, txn):
43- """Commit the transaction even though there should be no writes."""
44- if getFeatureFlag('webservice.read_only_commit.disabled'):
45- super(WebServicePublication, self).finishReadOnlyRequest(
46- request, ob, txn)
47- else:
48- # WebServicePublication used to commit on every request to store
49- # OAuthNonces to prevent replay attacks. But TLS prevents replay
50- # attacks too, so we don't bother with nonces any more. However,
51- # this commit will stay here until we can switch it off in a
52- # controlled test to ensure that nothing depends on it on prod.
53- notify(FinishReadOnlyRequestEvent(ob, request))
54- # Transaction commits usually need to be aware of the
55- # possibility of a doomed transaction. We do not expect that
56- # this code will encounter doomed transactions. If it does,
57- # this will need to be revisited.
58- txn.commit()
59-
60 def getPrincipal(self, request):
61 """See `LaunchpadBrowserPublication`.
62
63
64=== modified file 'lib/lp/services/webapp/tests/test_servers.py'
65--- lib/lp/services/webapp/tests/test_servers.py 2018-01-02 16:10:26 +0000
66+++ lib/lp/services/webapp/tests/test_servers.py 2018-01-25 13:17:27 +0000
67@@ -1,4 +1,4 @@
68-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
69+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
70 # GNU Affero General Public License version 3 (see the file LICENSE).
71
72 __metaclass__ = type
73@@ -31,7 +31,6 @@
74 )
75
76 from lp.app import versioninfo
77-from lp.services.features.testing import FeatureFixture
78 from lp.services.webapp.interfaces import IFinishReadOnlyRequestEvent
79 from lp.services.webapp.publication import LaunchpadBrowserPublication
80 from lp.services.webapp.servers import (
81@@ -53,10 +52,7 @@
82 EventRecorder,
83 TestCase,
84 )
85-from lp.testing.layers import (
86- FunctionalLayer,
87- ZopelessDatabaseLayer,
88- )
89+from lp.testing.layers import FunctionalLayer
90
91
92 class SetInWSGIEnvironmentTestCase(TestCase):
93@@ -699,7 +695,7 @@
94 self.log.append("ABORT")
95
96
97-class TestFinishReadOnlyRequestMixin:
98+class TestFinishReadOnlyRequest(TestCase):
99 # Publications that have a finishReadOnlyRequest() method are obliged to
100 # fire an IFinishReadOnlyRequestEvent.
101
102@@ -730,13 +726,11 @@
103 self.assertIs(fake_request, finish_event.request)
104 self.assertIs(fake_object, finish_event.object)
105
106-class TestFinishReadOnlyRequest(TestFinishReadOnlyRequestMixin, TestCase):
107-
108 def test_WebServicePub_fires_FinishReadOnlyRequestEvent(self):
109 # WebServicePublication.finishReadOnlyRequest() issues an
110- # IFinishReadOnlyRequestEvent and commits the transaction.
111+ # IFinishReadOnlyRequestEvent and aborts the transaction.
112 publication = WebServicePublication(None)
113- self._test_publication(publication, ["COMMIT"])
114+ self._test_publication(publication, ["ABORT"])
115
116 def test_LaunchpadBrowserPub_fires_FinishReadOnlyRequestEvent(self):
117 # LaunchpadBrowserPublication.finishReadOnlyRequest() issues an
118@@ -745,23 +739,6 @@
119 self._test_publication(publication, ["ABORT"])
120
121
122-class TestFinishReadOnlyRequestFeatureFlag(
123- TestFinishReadOnlyRequestMixin, TestCase):
124-
125- layer = ZopelessDatabaseLayer
126-
127- def test_WebServicePub_aborts_if_read_only_commit_disabled(self):
128- # If the webservice.read_only_commit.disabled feature flag is set,
129- # WebServicePublication.finishReadOnlyRequest() behaves like
130- # LaunchpadBrowserPublication.finishReadOnlyRequest() and aborts the
131- # transaction. (This is intended to be the default behaviour in
132- # future.)
133- self.useFixture(FeatureFixture(
134- {'webservice.read_only_commit.disabled': 'on'}))
135- publication = WebServicePublication(None)
136- self._test_publication(publication, ["ABORT"])
137-
138-
139 def test_suite():
140 suite = unittest.TestSuite()
141 suite.addTest(DocTestSuite(