| Index: chrome/common/extensions/docs/server2/local_renderer.py
|
| diff --git a/chrome/common/extensions/docs/server2/local_renderer.py b/chrome/common/extensions/docs/server2/local_renderer.py
|
| index 53ac33f0d61aca788bfc6269a31b5050ff98a948..61a6f671042bf67208ccda71ce146051a97d29b9 100644
|
| --- a/chrome/common/extensions/docs/server2/local_renderer.py
|
| +++ b/chrome/common/extensions/docs/server2/local_renderer.py
|
| @@ -2,24 +2,28 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -import os
|
| -import urlparse
|
| +import sys
|
|
|
| from render_servlet import RenderServlet
|
| -from fake_fetchers import ConfigureFakeFetchers
|
| +from server_instance import ServerInstance
|
| from servlet import Request
|
|
|
| +class _LocalRenderServletDelegate(object):
|
| + def CreateServerInstanceForChannel(self, channel):
|
| + return ServerInstance.ForLocal()
|
| +
|
| class LocalRenderer(object):
|
| '''Renders pages fetched from the local file system.
|
| '''
|
| - def __init__(self, base_dir):
|
| - self._base_dir = base_dir.replace(os.sep, '/').rstrip('/')
|
| -
|
| - def Render(self, path, headers=None, servlet=RenderServlet):
|
| - '''Renders |path|, returning a tuple of (status, contents, headers).
|
| - '''
|
| - headers = headers or {}
|
| - # TODO(kalman): do this via a LocalFileSystem not this fake AppEngine stuff.
|
| - ConfigureFakeFetchers(os.path.join(self._base_dir, 'docs'))
|
| - url_path = urlparse.urlparse(path.replace(os.sep, '/')).path
|
| - return servlet(Request(url_path, headers)).Get()
|
| + @staticmethod
|
| + def Render(path):
|
| + def render_path(path):
|
| + return RenderServlet(Request(path, 'http://localhost', {}),
|
| + _LocalRenderServletDelegate(),
|
| + default_channel='trunk').Get()
|
| + response = render_path(path)
|
| + while response.status in [301, 302]:
|
| + redirect = response.headers['Location']
|
| + sys.stderr.write('<!-- Redirected %s to %s -->\n' % (path, redirect))
|
| + response = render_path(redirect)
|
| + return response
|
|
|