| 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 from fnmatch import fnmatch | 5 from fnmatch import fnmatch |
| 6 import logging | 6 import logging |
| 7 import mimetypes | 7 import mimetypes |
| 8 import traceback | 8 import traceback |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 from sidenav_data_source import SidenavDataSource | 29 from sidenav_data_source import SidenavDataSource |
| 30 from subversion_file_system import SubversionFileSystem | 30 from subversion_file_system import SubversionFileSystem |
| 31 import svn_constants | 31 import svn_constants |
| 32 from template_data_source import TemplateDataSource | 32 from template_data_source import TemplateDataSource |
| 33 from test_object_store import TestObjectStore | 33 from test_object_store import TestObjectStore |
| 34 from third_party.json_schema_compiler.model import UnixName | 34 from third_party.json_schema_compiler.model import UnixName |
| 35 import url_constants | 35 import url_constants |
| 36 | 36 |
| 37 class ServerInstance(object): | 37 class ServerInstance(object): |
| 38 def __init__(self, | 38 def __init__(self, |
| 39 channel, | |
| 40 object_store_creator, | 39 object_store_creator, |
| 41 host_file_system, | 40 host_file_system, |
| 42 app_samples_file_system, | 41 app_samples_file_system, |
| 43 static_path, | 42 compiled_fs_factory, |
| 44 compiled_fs_factory): | 43 static_path): |
| 45 self.channel = channel | |
| 46 | |
| 47 self.object_store_creator = object_store_creator | 44 self.object_store_creator = object_store_creator |
| 48 | 45 |
| 49 self.host_file_system = host_file_system | 46 self.host_file_system = host_file_system |
| 50 | 47 |
| 51 self.app_samples_file_system = app_samples_file_system | 48 self.app_samples_file_system = app_samples_file_system |
| 52 | 49 |
| 53 self.compiled_host_fs_factory = compiled_fs_factory | 50 self.compiled_host_fs_factory = compiled_fs_factory |
| 54 | 51 |
| 55 self.api_list_data_source_factory = APIListDataSource.Factory( | 52 self.api_list_data_source_factory = APIListDataSource.Factory( |
| 56 self.compiled_host_fs_factory, | 53 self.compiled_host_fs_factory, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 self.api_data_source_factory.SetReferenceResolverFactory( | 66 self.api_data_source_factory.SetReferenceResolverFactory( |
| 70 self.ref_resolver_factory) | 67 self.ref_resolver_factory) |
| 71 | 68 |
| 72 # Note: samples are super slow in the dev server because it doesn't support | 69 # Note: samples are super slow in the dev server because it doesn't support |
| 73 # async fetch, so disable them. | 70 # async fetch, so disable them. |
| 74 if IsDevServer(): | 71 if IsDevServer(): |
| 75 extension_samples_fs = EmptyDirFileSystem() | 72 extension_samples_fs = EmptyDirFileSystem() |
| 76 else: | 73 else: |
| 77 extension_samples_fs = self.host_file_system | 74 extension_samples_fs = self.host_file_system |
| 78 self.samples_data_source_factory = SamplesDataSource.Factory( | 75 self.samples_data_source_factory = SamplesDataSource.Factory( |
| 79 channel, | |
| 80 extension_samples_fs, | 76 extension_samples_fs, |
| 81 CompiledFileSystem.Factory(extension_samples_fs, object_store_creator), | 77 CompiledFileSystem.Factory(extension_samples_fs, object_store_creator), |
| 82 self.app_samples_file_system, | 78 self.app_samples_file_system, |
| 83 CompiledFileSystem.Factory(self.app_samples_file_system, | 79 CompiledFileSystem.Factory(self.app_samples_file_system, |
| 84 object_store_creator), | 80 object_store_creator), |
| 85 self.ref_resolver_factory, | 81 self.ref_resolver_factory, |
| 86 svn_constants.EXAMPLES_PATH) | 82 svn_constants.EXAMPLES_PATH) |
| 87 | 83 |
| 88 self.api_data_source_factory.SetSamplesDataSourceFactory( | 84 self.api_data_source_factory.SetSamplesDataSourceFactory( |
| 89 self.samples_data_source_factory) | 85 self.samples_data_source_factory) |
| 90 | 86 |
| 91 self.intro_data_source_factory = IntroDataSource.Factory( | 87 self.intro_data_source_factory = IntroDataSource.Factory( |
| 92 self.compiled_host_fs_factory, | 88 self.compiled_host_fs_factory, |
| 93 self.ref_resolver_factory, | 89 self.ref_resolver_factory, |
| 94 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) | 90 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) |
| 95 | 91 |
| 96 self.sidenav_data_source_factory = SidenavDataSource.Factory( | 92 self.sidenav_data_source_factory = SidenavDataSource.Factory( |
| 97 self.compiled_host_fs_factory, | 93 self.compiled_host_fs_factory, |
| 98 svn_constants.JSON_PATH) | 94 svn_constants.JSON_PATH) |
| 99 | 95 |
| 100 self.template_data_source_factory = TemplateDataSource.Factory( | 96 self.template_data_source_factory = TemplateDataSource.Factory( |
| 101 channel, | |
| 102 self.api_data_source_factory, | 97 self.api_data_source_factory, |
| 103 self.api_list_data_source_factory, | 98 self.api_list_data_source_factory, |
| 104 self.intro_data_source_factory, | 99 self.intro_data_source_factory, |
| 105 self.samples_data_source_factory, | 100 self.samples_data_source_factory, |
| 106 self.sidenav_data_source_factory, | 101 self.sidenav_data_source_factory, |
| 107 self.compiled_host_fs_factory, | 102 self.compiled_host_fs_factory, |
| 108 self.ref_resolver_factory, | 103 self.ref_resolver_factory, |
| 109 svn_constants.PUBLIC_TEMPLATE_PATH, | 104 svn_constants.PUBLIC_TEMPLATE_PATH, |
| 110 svn_constants.PRIVATE_TEMPLATE_PATH, | 105 svn_constants.PRIVATE_TEMPLATE_PATH, |
| 111 static_path) | 106 static_path) |
| 112 | 107 |
| 113 self.example_zipper = ExampleZipper( | 108 self.example_zipper = ExampleZipper( |
| 114 self.compiled_host_fs_factory, | 109 self.compiled_host_fs_factory, |
| 115 svn_constants.DOCS_PATH) | 110 svn_constants.DOCS_PATH) |
| 116 | 111 |
| 117 self.path_canonicalizer = PathCanonicalizer( | 112 self.path_canonicalizer = PathCanonicalizer( |
| 118 channel, | |
| 119 self.compiled_host_fs_factory) | 113 self.compiled_host_fs_factory) |
| 120 | 114 |
| 121 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( | 115 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( |
| 122 ServerInstance) | 116 ServerInstance) |
| 123 | 117 |
| 124 @staticmethod | 118 @staticmethod |
| 125 def ForTest(file_system): | 119 def ForTest(file_system): |
| 126 object_store_creator = ObjectStoreCreator.ForTest() | 120 object_store_creator = ObjectStoreCreator.ForTest() |
| 127 return ServerInstance('test', | 121 return ServerInstance(object_store_creator, |
| 128 object_store_creator, | |
| 129 file_system, | 122 file_system, |
| 130 EmptyDirFileSystem(), | 123 EmptyDirFileSystem(), |
| 131 '/static', | |
| 132 CompiledFileSystem.Factory(file_system, | 124 CompiledFileSystem.Factory(file_system, |
| 133 object_store_creator)) | 125 object_store_creator), |
| 126 '/static') |
| 134 | 127 |
| 135 @staticmethod | 128 @staticmethod |
| 136 def ForLocal(): | 129 def ForLocal(): |
| 137 channel = 'trunk' | 130 object_store_creator = ObjectStoreCreator(start_empty=False, |
| 138 object_store_creator = ObjectStoreCreator(channel, | |
| 139 start_empty=False, | |
| 140 store_type=TestObjectStore) | 131 store_type=TestObjectStore) |
| 141 file_system = CachingFileSystem(LocalFileSystem.Create(), | 132 file_system = CachingFileSystem(LocalFileSystem.Create(), |
| 142 object_store_creator) | 133 object_store_creator) |
| 143 return ServerInstance( | 134 return ServerInstance( |
| 144 channel, | |
| 145 object_store_creator, | 135 object_store_creator, |
| 146 file_system, | 136 file_system, |
| 147 EmptyDirFileSystem(), | 137 EmptyDirFileSystem(), |
| 148 '/static', | 138 CompiledFileSystem.Factory(file_system, object_store_creator), |
| 149 CompiledFileSystem.Factory(file_system, object_store_creator)) | 139 '/static') |
| OLD | NEW |