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

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

Issue 10545043: Extensions docs server: Design changes, partial template support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made suggested changes Created 8 years, 6 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
(Empty)
1 # Copyright (c) 2012 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 import logging
6
7 DOCS_PATH = 'docs/'
8 STATIC_PATH = DOCS_PATH + 'static/'
9
10 class ServerInstance(object):
11 """This class is used to hold a data source and fetcher for an instance of a
12 server. Each new branch will get its own ServerInstance.
13 """
14 def __init__(self, data_source, fetcher):
15 self._data_source = data_source
16 self._fetcher = fetcher
17
18 def Run(self, path, request_handler):
19 parts = path.split('/')
20 filename = parts[-1]
21 content = self._data_source.Render(filename, '{"test": "Hello"}')
22 if not content:
23 logging.info('Template not found for: ' + filename)
24 try:
25 result = self._fetcher.FetchResource(STATIC_PATH + filename)
26 for key in result.headers:
27 request_handler.response.headers[key] = result.headers[key]
28 content = result.content
29 except:
30 request_handler.response.set_status(404)
31 # TODO should be an actual not found page.
32 content = 'File not found.'
33 logging.info
34 request_handler.response.out.write(content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698