| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 from StringIO import StringIO | 7 from StringIO import StringIO |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from appengine_wrappers import webapp | 10 from appengine_wrappers import webapp |
| 11 from appengine_wrappers import memcache | 11 from appengine_wrappers import memcache |
| 12 from appengine_wrappers import urlfetch | 12 from appengine_wrappers import urlfetch |
| 13 | 13 |
| 14 from api_data_source import APIDataSource | 14 from api_data_source import APIDataSource |
| 15 from api_list_data_source import APIListDataSource | 15 from api_list_data_source import APIListDataSource |
| 16 from appengine_blobstore import AppEngineBlobstore | 16 from appengine_blobstore import AppEngineBlobstore |
| 17 from in_memory_object_store import InMemoryObjectStore | 17 from in_memory_object_store import InMemoryObjectStore |
| 18 from appengine_url_fetcher import AppEngineUrlFetcher | 18 from appengine_url_fetcher import AppEngineUrlFetcher |
| 19 from branch_utility import BranchUtility | 19 from branch_utility import BranchUtility |
| 20 from example_zipper import ExampleZipper | 20 from example_zipper import ExampleZipper |
| 21 from compiled_file_system import CompiledFileSystem | 21 from compiled_file_system import CompiledFileSystem |
| 22 import compiled_file_system as compiled_fs | 22 import compiled_file_system as compiled_fs |
| 23 from github_file_system import GithubFileSystem | 23 from github_file_system import GithubFileSystem |
| 24 from intro_data_source import IntroDataSource | 24 from intro_data_source import IntroDataSource |
| 25 from known_issues_data_source import KnownIssuesDataSource | 25 from known_issues_data_source import KnownIssuesDataSource |
| 26 from local_file_system import LocalFileSystem | 26 from local_file_system import LocalFileSystem |
| 27 from memcache_file_system import MemcacheFileSystem | 27 from memcache_file_system import MemcacheFileSystem |
| 28 from reference_resolver import ReferenceResolver |
| 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 |
| 31 from template_data_source import TemplateDataSource | 32 from template_data_source import TemplateDataSource |
| 32 from third_party.json_schema_compiler.model import UnixName | 33 from third_party.json_schema_compiler.model import UnixName |
| 33 import url_constants | 34 import url_constants |
| 34 | 35 |
| 35 # The branch that the server will default to when no branch is specified in the | 36 # The branch that the server will default to when no branch is specified in the |
| 36 # URL. This is necessary because it is not possible to pass flags to the script | 37 # URL. This is necessary because it is not possible to pass flags to the script |
| 37 # handler. | 38 # handler. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 file_system = _CreateMemcacheFileSystem(branch, branch_memcache) | 125 file_system = _CreateMemcacheFileSystem(branch, branch_memcache) |
| 125 | 126 |
| 126 cache_factory = CompiledFileSystem.Factory(file_system, branch_memcache) | 127 cache_factory = CompiledFileSystem.Factory(file_system, branch_memcache) |
| 127 api_list_data_source_factory = APIListDataSource.Factory(cache_factory, | 128 api_list_data_source_factory = APIListDataSource.Factory(cache_factory, |
| 128 file_system, | 129 file_system, |
| 129 API_PATH, | 130 API_PATH, |
| 130 PUBLIC_TEMPLATE_PATH) | 131 PUBLIC_TEMPLATE_PATH) |
| 131 intro_data_source_factory = IntroDataSource.Factory( | 132 intro_data_source_factory = IntroDataSource.Factory( |
| 132 cache_factory, | 133 cache_factory, |
| 133 [INTRO_PATH, ARTICLE_PATH]) | 134 [INTRO_PATH, ARTICLE_PATH]) |
| 135 api_data_source_factory = APIDataSource.Factory( |
| 136 cache_factory, |
| 137 API_PATH) |
| 138 ref_resolver_factory = ReferenceResolver.Factory( |
| 139 api_data_source_factory.Create(None, disable_refs=True), |
| 140 api_list_data_source_factory.Create()) |
| 141 api_data_source_factory.SetReferenceResolverFactory(ref_resolver_factory) |
| 134 samples_data_source_factory = SamplesDataSource.Factory( | 142 samples_data_source_factory = SamplesDataSource.Factory( |
| 135 channel_name, | 143 channel_name, |
| 136 file_system, | 144 file_system, |
| 137 GITHUB_FILE_SYSTEM, | 145 GITHUB_FILE_SYSTEM, |
| 138 cache_factory, | 146 cache_factory, |
| 139 GITHUB_COMPILED_FILE_SYSTEM, | 147 GITHUB_COMPILED_FILE_SYSTEM, |
| 140 api_list_data_source_factory, | 148 ref_resolver_factory, |
| 141 EXAMPLES_PATH) | 149 EXAMPLES_PATH) |
| 142 api_data_source_factory = APIDataSource.Factory(cache_factory, | 150 api_data_source_factory.SetSamplesDataSourceFactory( |
| 143 API_PATH, | 151 samples_data_source_factory) |
| 144 samples_data_source_factory) | |
| 145 template_data_source_factory = TemplateDataSource.Factory( | 152 template_data_source_factory = TemplateDataSource.Factory( |
| 146 channel_name, | 153 channel_name, |
| 147 api_data_source_factory, | 154 api_data_source_factory, |
| 148 api_list_data_source_factory, | 155 api_list_data_source_factory, |
| 149 intro_data_source_factory, | 156 intro_data_source_factory, |
| 150 samples_data_source_factory, | 157 samples_data_source_factory, |
| 151 KNOWN_ISSUES_DATA_SOURCE, | 158 KNOWN_ISSUES_DATA_SOURCE, |
| 152 cache_factory, | 159 cache_factory, |
| 153 PUBLIC_TEMPLATE_PATH, | 160 PUBLIC_TEMPLATE_PATH, |
| 154 PRIVATE_TEMPLATE_PATH) | 161 PRIVATE_TEMPLATE_PATH) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 351 |
| 345 # Redirect paths like "directory" to "directory/". This is so relative | 352 # Redirect paths like "directory" to "directory/". This is so relative |
| 346 # file paths will know to treat this as a directory. | 353 # file paths will know to treat this as a directory. |
| 347 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 354 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
| 348 self.redirect(path + '/') | 355 self.redirect(path + '/') |
| 349 return | 356 return |
| 350 | 357 |
| 351 path = path.strip('/') | 358 path = path.strip('/') |
| 352 if not self._RedirectFromCodeDotGoogleDotCom(path): | 359 if not self._RedirectFromCodeDotGoogleDotCom(path): |
| 353 self._HandleGet(path) | 360 self._HandleGet(path) |
| OLD | NEW |