| Index: chrome/common/extensions/docs/server2/patch_servlet.py
|
| ===================================================================
|
| --- chrome/common/extensions/docs/server2/patch_servlet.py (revision 0)
|
| +++ chrome/common/extensions/docs/server2/patch_servlet.py (revision 0)
|
| @@ -0,0 +1,38 @@
|
| +# Copyright 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from appengine_wrappers import IsDevServer
|
| +from object_store_creator import ObjectStoreCreator
|
| +from render_servlet import RenderServlet
|
| +from server_instance import ServerInstance
|
| +from servlet import Request, Response, Servlet
|
| +
|
| +class PatchServlet(Servlet):
|
| + '''Servlet which renders patched docs.
|
| + '''
|
| +
|
| + def Get(self):
|
| + path_with_issue = self._request.path
|
| + if '/' in path_with_issue:
|
| + issue, real_path = path_with_issue.split('/', 1)
|
| + else:
|
| + issue, real_path = path_with_issue, ''
|
| +
|
| + constructor = (ServerInstance.CreateOnline if IsDevServer() else
|
| + ServerInstance.GetOrCreateOffline)
|
| + server_instance = constructor('trunk',
|
| + '/_patch/%s/static' % issue,
|
| + issue)
|
| + fake_path = '/trunk/%s' % real_path
|
| +
|
| + response = RenderServlet(Request(
|
| + fake_path,
|
| + self._request.headers)).Get(server_instance)
|
| +
|
| + if response.IsRedirect():
|
| + url = response.headers['Location']
|
| + if url.startswith('/trunk/'):
|
| + url = url.split('/trunk', 1)[1]
|
| + response.headers['Location'] = '/_patch/%s%s' % (issue, url)
|
| + return response
|
|
|
| Property changes on: chrome/common/extensions/docs/server2/patch_servlet.py
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|