Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (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 object_store_creator import ObjectStoreCreator | |
| 6 from render_servlet import _ALWAYS_ONLINE, RenderServlet | |
| 7 from server_instance import ServerInstance | |
| 8 from servlet import Request, Response, Servlet | |
| 9 | |
| 10 class PatchServlet(Servlet): | |
| 11 '''Servlet which renders patched docs. | |
| 12 ''' | |
| 13 | |
| 14 def Get(self): | |
| 15 path_with_issue = self._request.path.lstrip('/') | |
|
not at google - send to devlin
2013/05/03 19:12:22
'/' is already been lstripped in Handler.
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
| |
| 16 if '/' in path_with_issue: | |
| 17 issue, real_path = path_with_issue.split('/', 1) | |
| 18 else: | |
| 19 issue = path_with_issue | |
| 20 real_path = '' | |
|
not at google - send to devlin
2013/05/03 19:12:22
I like the pattern of doing "issue, real_path = (p
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
| |
| 21 if not issue.isdigit(): | |
| 22 return Response.Redirect('/' + path_with_issue) | |
|
not at google - send to devlin
2013/05/03 19:12:22
Why does the issue need to be a number? We show a
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
| |
| 23 elif len(real_path) == 0: | |
|
not at google - send to devlin
2013/05/03 19:12:22
these can be if not elif since the preceding state
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
When I tested it, I found a bug in RenderSer
| |
| 24 return Response.Redirect('/_patch/%s/extensions/index.html' % issue) | |
| 25 elif real_path in ['apps', 'apps/']: | |
| 26 return Response.Redirect('/_patch/%s/apps/about_apps.html' % issue) | |
| 27 elif real_path in ['extensions', 'extensions/']: | |
| 28 return Response.Redirect('/_patch/%s/extensions/index.html' % issue) | |
| 29 | |
| 30 constructor = (ServerInstance.CreateOnline if _ALWAYS_ONLINE else | |
|
not at google - send to devlin
2013/05/03 19:12:22
ALWAYS_ONLINE is about to be deleted, use IsDevSer
方觉(Fang Jue)
2013/05/04 02:05:41
Done.
| |
| 31 ServerInstance.GetOrCreateOffline) | |
| 32 server_instance = constructor('trunk', | |
| 33 '/_patch/%s/' % issue, | |
| 34 issue) | |
| 35 fake_path = '/trunk/%s' % real_path | |
| 36 | |
| 37 return RenderServlet(Request(fake_path, | |
| 38 self._request.headers)).Get(server_instance) | |
| OLD | NEW |