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

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

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revisions, Offline/Online Access (bypassed-hooks) 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
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 CreateServerInstanceForChannel(self, channel):
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 path.contains('\\') 21 assert not '\\' in path
epeterson 2013/05/13 02:38:10 This should probably just be put in its own patch
not at google - send to devlin 2013/05/13 21:26:41 yeah it's been fixed now, you can revert it
22 def render_path(path): 22 def render_path(path):
23 return RenderServlet(Request(path, 'http://localhost', {}), 23 return RenderServlet(Request(path, 'http://localhost', {}),
24 _LocalRenderServletDelegate(), 24 _LocalRenderServletDelegate(),
25 default_channel='trunk').Get() 25 default_channel='trunk').Get()
26 response = render_path(path) 26 response = render_path(path)
27 while response.status in [301, 302]: 27 while response.status in [301, 302]:
28 redirect = response.headers['Location'] 28 redirect = response.headers['Location']
29 sys.stderr.write('<!-- Redirected %s to %s -->\n' % (path, redirect)) 29 sys.stderr.write('<!-- Redirected %s to %s -->\n' % (path, redirect))
30 response = render_path(redirect) 30 response = render_path(redirect)
31 return response 31 return response
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698