Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 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, | 39 channel, |
| 40 object_store_creator, | 40 object_store_creator, |
| 41 host_file_system, | 41 host_file_system, |
| 42 app_samples_file_system): | 42 app_samples_file_system, |
| 43 static_path=None, | |
| 44 compiled_fs_factory=None): | |
|
not at google - send to devlin
2013/05/11 20:39:53
having these as optional parameters doesn't gain m
| |
| 43 self.channel = channel | 45 self.channel = channel |
| 44 | 46 |
| 45 self.object_store_creator = object_store_creator | 47 self.object_store_creator = object_store_creator |
| 46 | 48 |
| 47 self.host_file_system = host_file_system | 49 self.host_file_system = host_file_system |
| 48 | 50 |
| 49 self.app_samples_file_system = app_samples_file_system | 51 self.app_samples_file_system = app_samples_file_system |
| 50 | 52 |
| 51 self.compiled_host_fs_factory = CompiledFileSystem.Factory( | 53 if compiled_fs_factory is None: |
| 52 host_file_system, | 54 self.compiled_host_fs_factory = CompiledFileSystem.Factory( |
| 53 object_store_creator) | 55 host_file_system, |
| 56 object_store_creator) | |
| 57 else: | |
| 58 self.compiled_host_fs_factory = compiled_fs_factory | |
| 54 | 59 |
| 55 self.api_list_data_source_factory = APIListDataSource.Factory( | 60 self.api_list_data_source_factory = APIListDataSource.Factory( |
| 56 self.compiled_host_fs_factory, | 61 self.compiled_host_fs_factory, |
| 57 svn_constants.API_PATH, | 62 svn_constants.API_PATH, |
| 58 svn_constants.PUBLIC_TEMPLATE_PATH) | 63 svn_constants.PUBLIC_TEMPLATE_PATH) |
| 59 | 64 |
| 60 self.api_data_source_factory = APIDataSource.Factory( | 65 self.api_data_source_factory = APIDataSource.Factory( |
| 61 self.compiled_host_fs_factory, | 66 self.compiled_host_fs_factory, |
| 62 svn_constants.API_PATH) | 67 svn_constants.API_PATH) |
| 63 | 68 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 90 | 95 |
| 91 self.intro_data_source_factory = IntroDataSource.Factory( | 96 self.intro_data_source_factory = IntroDataSource.Factory( |
| 92 self.compiled_host_fs_factory, | 97 self.compiled_host_fs_factory, |
| 93 self.ref_resolver_factory, | 98 self.ref_resolver_factory, |
| 94 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) | 99 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) |
| 95 | 100 |
| 96 self.sidenav_data_source_factory = SidenavDataSource.Factory( | 101 self.sidenav_data_source_factory = SidenavDataSource.Factory( |
| 97 self.compiled_host_fs_factory, | 102 self.compiled_host_fs_factory, |
| 98 svn_constants.JSON_PATH) | 103 svn_constants.JSON_PATH) |
| 99 | 104 |
| 105 if static_path is None: | |
| 106 static_path = '/static' if channel == 'stable' else '/%s/static' % channel | |
| 100 self.template_data_source_factory = TemplateDataSource.Factory( | 107 self.template_data_source_factory = TemplateDataSource.Factory( |
| 101 channel, | 108 channel, |
| 102 self.api_data_source_factory, | 109 self.api_data_source_factory, |
| 103 self.api_list_data_source_factory, | 110 self.api_list_data_source_factory, |
| 104 self.intro_data_source_factory, | 111 self.intro_data_source_factory, |
| 105 self.samples_data_source_factory, | 112 self.samples_data_source_factory, |
| 106 self.sidenav_data_source_factory, | 113 self.sidenav_data_source_factory, |
| 107 self.compiled_host_fs_factory, | 114 self.compiled_host_fs_factory, |
| 108 self.ref_resolver_factory, | 115 self.ref_resolver_factory, |
| 109 svn_constants.PUBLIC_TEMPLATE_PATH, | 116 svn_constants.PUBLIC_TEMPLATE_PATH, |
| 110 svn_constants.PRIVATE_TEMPLATE_PATH) | 117 svn_constants.PRIVATE_TEMPLATE_PATH, |
| 118 static_path) | |
| 111 | 119 |
| 112 self.example_zipper = ExampleZipper( | 120 self.example_zipper = ExampleZipper( |
| 113 self.compiled_host_fs_factory, | 121 self.compiled_host_fs_factory, |
| 114 svn_constants.DOCS_PATH) | 122 svn_constants.DOCS_PATH) |
| 115 | 123 |
| 116 self.path_canonicalizer = PathCanonicalizer( | 124 self.path_canonicalizer = PathCanonicalizer( |
| 117 channel, | 125 channel, |
| 118 self.compiled_host_fs_factory) | 126 self.compiled_host_fs_factory) |
| 119 | 127 |
| 120 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( | 128 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 131 def ForLocal(): | 139 def ForLocal(): |
| 132 channel = 'trunk' | 140 channel = 'trunk' |
| 133 object_store_creator = ObjectStoreCreator(channel, | 141 object_store_creator = ObjectStoreCreator(channel, |
| 134 start_empty=False, | 142 start_empty=False, |
| 135 store_type=TestObjectStore) | 143 store_type=TestObjectStore) |
| 136 return ServerInstance( | 144 return ServerInstance( |
| 137 channel, | 145 channel, |
| 138 object_store_creator, | 146 object_store_creator, |
| 139 CachingFileSystem(LocalFileSystem.Create(), object_store_creator), | 147 CachingFileSystem(LocalFileSystem.Create(), object_store_creator), |
| 140 EmptyDirFileSystem()) | 148 EmptyDirFileSystem()) |
| OLD | NEW |