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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 7
8 from render_servlet import RenderServlet 8 from render_servlet import RenderServlet
9 from server_instance import ServerInstance 9 from server_instance import ServerInstance
10 from servlet import Request 10 from servlet import Request
11 11
12 class _LocalRenderServletDelegate(object): 12 class _LocalRenderServletDelegate(object):
13 def CreateServerInstanceForChannel(self, channel): 13 def CreateServerInstance(self):
14 return ServerInstance.ForLocal() 14 return ServerInstance.ForLocal()
15 15
16 class LocalRenderer(object): 16 class LocalRenderer(object):
17 '''Renders pages fetched from the local file system. 17 '''Renders pages fetched from the local file system.
18 ''' 18 '''
19 @staticmethod 19 @staticmethod
20 def Render(path): 20 def Render(path):
21 assert not '\\' in path 21 assert not '\\' in path
22 def render_path(path): 22 return RenderServlet(Request.ForTest(path),
23 return RenderServlet(Request(path, 'http://localhost', {}), 23 _LocalRenderServletDelegate()).Get()
24 _LocalRenderServletDelegate(),
25 default_channel='trunk').Get()
26 response = render_path(path)
27 while response.status in [301, 302]:
28 redirect = response.headers['Location']
29 sys.stderr.write('<!-- Redirected %s to %s -->\n' % (path, redirect))
30 response = render_path(redirect)
31 return response
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/integration_test.py ('k') | chrome/common/extensions/docs/server2/object_store.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698