Merge lp:~lifeless/launchpad/librarian-filealiases into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12041
Proposed branch: lp:~lifeless/launchpad/librarian-filealiases
Merge into: lp:launchpad
Diff against target: 307 lines (+16/-118)
7 files modified
lib/canonical/launchpad/browser/librarian.py (+3/-4)
lib/canonical/launchpad/rest/bytestorage.py (+0/-28)
lib/canonical/launchpad/webapp/servers.py (+11/-14)
lib/canonical/launchpad/zcml/webservice.zcml (+0/-13)
lib/lp/bugs/interfaces/bugattachment.py (+2/-2)
lib/lp/bugs/stories/webservice/xx-bug.txt (+0/-40)
lib/lp/services/fields/__init__.py (+0/-17)
To merge this branch: bzr merge lp:~lifeless/launchpad/librarian-filealiases
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+41233@code.launchpad.net

Commit message

Revert the hack for apport from the restricted library file code.

Description of the change

Revert the workaround commit we had to let apport work; also includes a docstring fix.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This is just a revert, no brainer.

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/browser/librarian.py'
2--- lib/canonical/launchpad/browser/librarian.py 2010-11-08 12:52:43 +0000
3+++ lib/canonical/launchpad/browser/librarian.py 2010-11-18 21:04:17 +0000
4@@ -259,16 +259,15 @@
5
6 The URL's output by this decorator will always point at the webapp. This is
7 useful when:
8- - we are proxying files via the webapp (as we do at the moment)
9- - when the webapp has to be contacted to get access to a file (the case
10- for restricted files in the future)
11+ - the webapp has to be contacted to get access to a file (required for
12+ restricted files).
13 - files might change from public to private and thus not work even if the
14 user has access to the once its private, unless they go via the webapp.
15
16 This should be used anywhere we are outputting URL's to LibraryFileAliases
17 other than directly in rendered pages. For rendered pages, using a
18 LibraryFileAlias directly is OK as at that point the status of the file
19- is know.
20+ is known.
21
22 Overrides `ILibraryFileAlias.http_url` to always point to the webapp URL,
23 even when called from the webservice domain.
24
25=== modified file 'lib/canonical/launchpad/rest/bytestorage.py'
26--- lib/canonical/launchpad/rest/bytestorage.py 2010-09-03 20:28:36 +0000
27+++ lib/canonical/launchpad/rest/bytestorage.py 2010-11-18 21:04:17 +0000
28@@ -6,7 +6,6 @@
29 __metaclass__ = type
30 __all__ = [
31 'LibraryBackedByteStorage',
32- 'RestrictedLibraryBackedByteStorage',
33 ]
34
35
36@@ -16,7 +15,6 @@
37 from zope.component import getUtility
38 from zope.interface import implements
39
40-from canonical.launchpad.browser.librarian import ProxiedLibraryFileAlias
41 from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
42 from canonical.launchpad.webapp.interfaces import ICanonicalUrlData
43
44@@ -75,29 +73,3 @@
45 def deleteStored(self):
46 """See `IByteStorage`."""
47 setattr(self.entry, self.field.__name__, None)
48-
49-
50-class RestrictedLibraryBackedByteStorage(LibraryBackedByteStorage):
51- """See `IByteStorage`.
52-
53- This variant of LibraryBackedByteStorage provides an alias_url
54- which points to a StreamOrRedirectLibraryFileAliasView for
55- restricted Librarian files.
56- """
57-
58- @property
59- def alias_url(self):
60- """See `IByteStorage`."""
61- if self.file_alias.restricted:
62- # XXX Abel Deuring 2010-09-03, bug=629804
63- # This is a bad hack: We can't give ordinary users API access to
64- # restricted files at present. But we can allow access to
65- # some machines in the data center (and should do that).
66- # We need here an HTTP URL, not an HTTPS URL, so we don't
67- # use getUrl(). Since http_url uses not an official domain
68- # name, all we do is expose an unaccessible HTTP URL also
69- # users outside of the data center, instead of the HTTPS URL
70- # returned by getURL().
71- return self.file_alias.http_url
72- else:
73- return self.file_alias.getURL()
74
75=== modified file 'lib/canonical/launchpad/webapp/servers.py'
76--- lib/canonical/launchpad/webapp/servers.py 2010-11-03 13:44:35 +0000
77+++ lib/canonical/launchpad/webapp/servers.py 2010-11-18 21:04:17 +0000
78@@ -1293,19 +1293,10 @@
79 return principal
80
81
82-class LaunchpadWebServiceRequestTraversal(WebServiceRequestTraversal):
83- implements(canonical.launchpad.layers.WebServiceLayer)
84-
85- def getRootURL(self, rootsite):
86- """See IBasicLaunchpadRequest."""
87- # When browsing the web service, we want URLs to point back at the web
88- # service, so we basically ignore rootsite.
89- return self.getApplicationURL() + '/'
90-
91-
92-class WebServiceClientRequest(LaunchpadWebServiceRequestTraversal,
93+class WebServiceClientRequest(WebServiceRequestTraversal,
94 LaunchpadBrowserRequest):
95 """Request type for a resource published through the web service."""
96+ implements(canonical.launchpad.layers.WebServiceLayer)
97
98 def __init__(self, body_instream, environ, response=None):
99 super(WebServiceClientRequest, self).__init__(
100@@ -1331,14 +1322,20 @@
101 # than ETag, we may have to revisit this.
102 self.response.setHeader('Vary', 'Accept')
103
104-
105-class WebServiceTestRequest(LaunchpadWebServiceRequestTraversal,
106- LaunchpadTestRequest):
107+ def getRootURL(self, rootsite):
108+ """See IBasicLaunchpadRequest."""
109+ # When browsing the web service, we want URLs to point back at the web
110+ # service, so we basically ignore rootsite.
111+ return self.getApplicationURL() + '/'
112+
113+
114+class WebServiceTestRequest(WebServiceRequestTraversal, LaunchpadTestRequest):
115 """Test request for the webservice.
116
117 It provides the WebServiceLayer and supports the getResource()
118 web publication hook.
119 """
120+ implements(canonical.launchpad.layers.WebServiceLayer)
121
122 def __init__(self, body_instream=None, environ=None, version=None, **kw):
123 test_environ = {
124
125=== modified file 'lib/canonical/launchpad/zcml/webservice.zcml'
126--- lib/canonical/launchpad/zcml/webservice.zcml 2010-11-09 14:35:44 +0000
127+++ lib/canonical/launchpad/zcml/webservice.zcml 2010-11-18 21:04:17 +0000
128@@ -43,19 +43,6 @@
129 <allow interface='lazr.restful.interfaces.IByteStorage' />
130 </class>
131
132- <!-- Registration for the class that manages an entry's RestrictedBytes
133- fields. -->
134- <adapter
135- for="lazr.restful.interfaces.IEntry
136- lp.services.fields.IRestrictedBytes"
137- provides="lazr.restful.interfaces.IByteStorage"
138- factory="canonical.launchpad.rest.bytestorage.RestrictedLibraryBackedByteStorage"
139- />
140-
141- <class class="canonical.launchpad.rest.bytestorage.RestrictedLibraryBackedByteStorage">
142- <allow interface='lazr.restful.interfaces.IByteStorage' />
143- </class>
144-
145 <!-- WebService uses the default LaunchpadRootNavigation -->
146 <view
147 for="canonical.launchpad.interfaces.launchpad.IWebServiceApplication"
148
149=== modified file 'lib/lp/bugs/interfaces/bugattachment.py'
150--- lib/lp/bugs/interfaces/bugattachment.py 2010-11-02 19:54:59 +0000
151+++ lib/lp/bugs/interfaces/bugattachment.py 2010-11-18 21:04:17 +0000
152@@ -39,7 +39,7 @@
153 from canonical.launchpad import _
154 from canonical.launchpad.interfaces.launchpad import IHasBug
155 from canonical.launchpad.interfaces.message import IMessage
156-from lp.services.fields import RestrictedBytes, Title
157+from lp.services.fields import Title
158
159
160 class BugAttachmentType(DBEnumeratedType):
161@@ -115,7 +115,7 @@
162 libraryfile = Bytes(title=_("The attachment content."),
163 required=True)
164 data = exported(
165- RestrictedBytes(title=_("The attachment content."),
166+ Bytes(title=_("The attachment content."),
167 required=True,
168 readonly=True))
169 message = exported(
170
171=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
172--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-10-22 13:58:41 +0000
173+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-11-18 21:04:17 +0000
174@@ -1360,46 +1360,6 @@
175 ---
176
177
178-Attachments of private bugs
179-~~~~~~~~~~~~~~~~~~~~~~~~~~~
180-
181-Attachments of private bugs are served by the app server itself.
182-
183- >>> print webservice.patch(
184- ... bug_one['self_link'], 'application/json', dumps(dict(private=True)))
185- HTTP/1.1 209 Content Returned...
186-
187- >>> response = webservice.named_post(
188- ... bug_one['self_link'], 'addAttachment',
189- ... data="67890", filename="more-numbers.txt", content_type='foo/bar',
190- ... comment="The numbers you asked for.")
191- >>> attachments = webservice.get(
192- ... bug_one['attachments_collection_link']).jsonBody()
193- >>> attachment = attachments['entries'][0]
194- >>> pprint_entry(attachment)
195- bug_link:...
196- data_link: u'http://api.launchpad.dev/beta/bugs/1/+attachment/.../data'
197- ...
198-
199-XXX Abel Deuring 2010-09-03, bug=629804: Please note that the http URLs in this
200-example are part of a temporary hack. Please see the comment in
201-canonical.launchpad.rest.bytestorage.RestrictedLibraryBackedByteStorage.
202-alias_url for details.
203-
204- >>> response = webservice.get(attachment['data_link'])
205- >>> print response
206- HTTP/1.1 303 See Other
207- Status: 303 See Other
208- ...
209- Location: http://localhost:58005/94/more-numbers.txt
210- ...
211-
212- >>> # Let's make the bug public again for later tests.
213- >>> print webservice.patch(
214- ... bug_one['self_link'], 'application/json', dumps(dict(private=False)))
215- HTTP/1.1 209 Content Returned...
216-
217-
218 Searching for bugs
219 ------------------
220
221
222=== modified file 'lib/lp/services/fields/__init__.py'
223--- lib/lp/services/fields/__init__.py 2010-10-23 16:45:43 +0000
224+++ lib/lp/services/fields/__init__.py 2010-11-18 21:04:17 +0000
225@@ -22,7 +22,6 @@
226 'ILocationField',
227 'INoneableTextLine',
228 'IPasswordField',
229- 'IRestrictedBytes',
230 'IStrippedTextLine',
231 'ISummary',
232 'ITag',
233@@ -46,7 +45,6 @@
234 'ProductBugTracker',
235 'ProductNameField',
236 'PublicPersonChoice',
237- 'RestrictedBytes',
238 'SearchTag',
239 'StrippedTextLine',
240 'Summary',
241@@ -113,7 +111,6 @@
242
243
244 # Field Interfaces
245-
246 class IStrippedTextLine(ITextLine):
247 """A field with leading and trailing whitespaces stripped."""
248
249@@ -229,10 +226,6 @@
250 """
251
252
253-class IRestrictedBytes(IBytes):
254- """A marker interface used for restricted LibraryFileAlias fields."""
255-
256-
257 class StrippedTextLine(TextLine):
258 implements(IStrippedTextLine)
259
260@@ -248,7 +241,6 @@
261
262 # Title
263 # A field to capture a launchpad object title
264-
265 class Title(StrippedTextLine):
266 implements(ITitle)
267
268@@ -269,14 +261,12 @@
269
270 # Summary
271 # A field capture a Launchpad object summary
272-
273 class Summary(StrippableText):
274 implements(ISummary)
275
276
277 # Description
278 # A field capture a Launchpad object description
279-
280 class Description(StrippableText):
281 implements(IDescription)
282
283@@ -287,7 +277,6 @@
284
285 # Whiteboard
286 # A field capture a Launchpad object whiteboard
287-
288 class Whiteboard(StrippableText):
289 implements(IWhiteboard)
290
291@@ -321,7 +310,6 @@
292 # TimeInterval
293 # A field to capture an interval in time, such as X days, Y hours, Z
294 # minutes.
295-
296 class TimeInterval(TextLine):
297 implements(ITimeInterval)
298
299@@ -842,8 +830,3 @@
300 else:
301 # The vocabulary prevents the revealing of private team names.
302 raise PrivateTeamNotAllowed(value)
303-
304-
305-class RestrictedBytes(Bytes):
306- """A field for restricted LibraryFileAlias records."""
307- implements(IRestrictedBytes)