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

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 object_store_creator import ObjectStoreCreator
7 from render_servlet import RenderServlet
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:
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 response = RenderServlet(Request(
30 fake_path,
31 self._request.headers)).Get(server_instance)
32
33 if response.IsRedirect():
34 url = response.headers['Location']
35 if url.startswith('/trunk/'):
36 url = url.split('/trunk', 1)[1]
37 response.headers['Location'] = '/_patch/%s%s' % (issue, url)
38 return response
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698