Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: chrome/common/extensions/docs/server2/patch_servlet.py

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from appengine_wrappers import IsDevServer
6 from render_servlet import RenderServlet
7 from rietveld_patcher import RietveldPatcherError
8 from server_instance import ServerInstance
9 from servlet import Request, Response, Servlet
10
11 class PatchServlet(Servlet):
12 '''Servlet which renders patched docs.
13 '''
14
15 def Get(self):
16 path_with_issue = self._request.path
17 if '/' in path_with_issue:
not at google - send to devlin 2013/05/07 05:45:40 well if there isn't a '/' then it's a malformed, s
方觉(Fang Jue) 2013/05/07 06:03:55 Done.
18 issue, real_path = path_with_issue.split('/', 1)
19 else:
20 issue, real_path = path_with_issue, ''
21
22 constructor = (ServerInstance.CreateOnline if IsDevServer() else
23 ServerInstance.GetOrCreateOffline)
24 server_instance = constructor('trunk',
25 '/_patch/%s/static' % issue,
26 issue)
27 fake_path = '/trunk/%s' % real_path
28
29 try:
30 response = RenderServlet(Request(
31 fake_path,
32 self._request.headers)).Get(server_instance)
33 # Disable cache for patched content.
not at google - send to devlin 2013/05/07 05:45:40 you can do "response.headers.pop('cache-control',
方觉(Fang Jue) 2013/05/07 06:03:55 Done.
34 if response.headers.get('cache-control'):
35 del response.headers['cache-control']
36 except RietveldPatcherError as e:
37 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'})
not at google - send to devlin 2013/05/07 05:45:40 would kind of rather prefer to leave the content-t
方觉(Fang Jue) 2013/05/07 06:03:55 I just don't want any HTML injected in URL to be r
not at google - send to devlin 2013/05/07 06:17:21 Ok cool. We should either enforce that there's a c
38
39 if response.IsRedirect():
40 url = response.headers['Location']
41 if url.startswith('/trunk/'):
42 url = url.split('/trunk', 1)[1]
43 response.headers['Location'] = '/_patch/%s%s' % (issue, url)
44 return response
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698