| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 # Add the original server location to sys.path so we are able to import | 10 # Add the original server location to sys.path so we are able to import |
| 11 # modules from there. | 11 # modules from there. |
| 12 SERVER_PATH = 'chrome/common/extensions/docs/server2' | 12 SERVER_PATH = 'chrome/common/extensions/docs/server2' |
| 13 if os.path.abspath(SERVER_PATH) not in sys.path: | 13 if os.path.abspath(SERVER_PATH) not in sys.path: |
| 14 sys.path.append(os.path.abspath(SERVER_PATH)) | 14 sys.path.append(os.path.abspath(SERVER_PATH)) |
| 15 | 15 |
| 16 from google.appengine.ext import webapp | 16 from google.appengine.ext import webapp |
| 17 from google.appengine.api import memcache | 17 from google.appengine.api import memcache |
| 18 from google.appengine.ext.webapp.util import run_wsgi_app | 18 from google.appengine.ext.webapp.util import run_wsgi_app |
| 19 | 19 |
| 20 from api_data_source import APIDataSource | 20 from api_data_source import APIDataSource |
| 21 from api_list_data_source import APIListDataSource |
| 21 from appengine_memcache import AppEngineMemcache | 22 from appengine_memcache import AppEngineMemcache |
| 22 from branch_utility import BranchUtility | 23 from branch_utility import BranchUtility |
| 23 from example_zipper import ExampleZipper | 24 from example_zipper import ExampleZipper |
| 24 from file_system_cache import FileSystemCache | 25 from file_system_cache import FileSystemCache |
| 25 from intro_data_source import IntroDataSource | 26 from intro_data_source import IntroDataSource |
| 26 from local_file_system import LocalFileSystem | 27 from local_file_system import LocalFileSystem |
| 27 from memcache_file_system import MemcacheFileSystem | 28 from memcache_file_system import MemcacheFileSystem |
| 28 from samples_data_source import SamplesDataSource | 29 from samples_data_source import SamplesDataSource |
| 29 from server_instance import ServerInstance | 30 from server_instance import ServerInstance |
| 30 from subversion_file_system import SubversionFileSystem | 31 from subversion_file_system import SubversionFileSystem |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if branch == 'local': | 72 if branch == 'local': |
| 72 file_system = LocalFileSystem(EXTENSIONS_PATH) | 73 file_system = LocalFileSystem(EXTENSIONS_PATH) |
| 73 else: | 74 else: |
| 74 fetcher = AppEngineUrlFetcher( | 75 fetcher = AppEngineUrlFetcher( |
| 75 _GetURLFromBranch(branch) + '/' + EXTENSIONS_PATH) | 76 _GetURLFromBranch(branch) + '/' + EXTENSIONS_PATH) |
| 76 file_system = MemcacheFileSystem(SubversionFileSystem(fetcher), | 77 file_system = MemcacheFileSystem(SubversionFileSystem(fetcher), |
| 77 AppEngineMemcache(branch, memcache)) | 78 AppEngineMemcache(branch, memcache)) |
| 78 | 79 |
| 79 cache_builder = FileSystemCache.Builder(file_system) | 80 cache_builder = FileSystemCache.Builder(file_system) |
| 80 api_data_source = APIDataSource(cache_builder, API_PATH) | 81 api_data_source = APIDataSource(cache_builder, API_PATH) |
| 82 api_list_data_source = APIListDataSource(cache_builder, |
| 83 file_system, |
| 84 API_PATH, |
| 85 PUBLIC_TEMPLATE_PATH) |
| 81 intro_data_source = IntroDataSource(cache_builder, | 86 intro_data_source = IntroDataSource(cache_builder, |
| 82 [INTRO_PATH, ARTICLE_PATH]) | 87 [INTRO_PATH, ARTICLE_PATH]) |
| 83 samples_data_source = SamplesDataSource(file_system, | 88 samples_data_source = SamplesDataSource(file_system, |
| 84 cache_builder, | 89 cache_builder, |
| 85 EXAMPLES_PATH) | 90 EXAMPLES_PATH) |
| 86 template_data_source_factory = TemplateDataSource.Factory( | 91 template_data_source_factory = TemplateDataSource.Factory( |
| 87 branch, | 92 branch, |
| 88 api_data_source, | 93 api_data_source, |
| 94 api_list_data_source, |
| 89 intro_data_source, | 95 intro_data_source, |
| 90 samples_data_source, | 96 samples_data_source, |
| 91 cache_builder, | 97 cache_builder, |
| 92 [PUBLIC_TEMPLATE_PATH, PRIVATE_TEMPLATE_PATH]) | 98 [PUBLIC_TEMPLATE_PATH, PRIVATE_TEMPLATE_PATH]) |
| 93 example_zipper = ExampleZipper(file_system, | 99 example_zipper = ExampleZipper(file_system, |
| 94 cache_builder, | 100 cache_builder, |
| 95 DOCS_PATH, | 101 DOCS_PATH, |
| 96 EXAMPLES_PATH) | 102 EXAMPLES_PATH) |
| 97 SERVER_INSTANCES[branch] = ServerInstance( | 103 SERVER_INSTANCES[branch] = ServerInstance( |
| 98 template_data_source_factory, | 104 template_data_source_factory, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 128 | 134 |
| 129 def main(): | 135 def main(): |
| 130 handlers = [ | 136 handlers = [ |
| 131 ('/.*', Handler), | 137 ('/.*', Handler), |
| 132 ] | 138 ] |
| 133 run_wsgi_app(webapp.WSGIApplication(handlers, debug=False)) | 139 run_wsgi_app(webapp.WSGIApplication(handlers, debug=False)) |
| 134 | 140 |
| 135 | 141 |
| 136 if __name__ == '__main__': | 142 if __name__ == '__main__': |
| 137 main() | 143 main() |
| OLD | NEW |