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 22 matching lines...) Expand all Loading... |
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, | 43 base_path, |
44 compiled_fs_factory): | 44 compiled_fs_factory): |
45 self.channel = channel | 45 self.channel = channel |
46 | 46 |
47 self.object_store_creator = object_store_creator | 47 self.object_store_creator = object_store_creator |
48 | 48 |
49 self.host_file_system = host_file_system | 49 self.host_file_system = host_file_system |
50 | 50 |
51 self.app_samples_file_system = app_samples_file_system | 51 self.app_samples_file_system = app_samples_file_system |
52 | 52 |
53 self.compiled_host_fs_factory = compiled_fs_factory | 53 self.compiled_host_fs_factory = compiled_fs_factory |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 self.api_data_source_factory.SetSamplesDataSourceFactory( | 88 self.api_data_source_factory.SetSamplesDataSourceFactory( |
89 self.samples_data_source_factory) | 89 self.samples_data_source_factory) |
90 | 90 |
91 self.intro_data_source_factory = IntroDataSource.Factory( | 91 self.intro_data_source_factory = IntroDataSource.Factory( |
92 self.compiled_host_fs_factory, | 92 self.compiled_host_fs_factory, |
93 self.ref_resolver_factory, | 93 self.ref_resolver_factory, |
94 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) | 94 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) |
95 | 95 |
96 self.sidenav_data_source_factory = SidenavDataSource.Factory( | 96 self.sidenav_data_source_factory = SidenavDataSource.Factory( |
97 self.compiled_host_fs_factory, | 97 self.compiled_host_fs_factory, |
98 svn_constants.JSON_PATH) | 98 svn_constants.JSON_PATH, |
| 99 base_path) |
99 | 100 |
100 self.template_data_source_factory = TemplateDataSource.Factory( | 101 self.template_data_source_factory = TemplateDataSource.Factory( |
101 channel, | 102 channel, |
102 self.api_data_source_factory, | 103 self.api_data_source_factory, |
103 self.api_list_data_source_factory, | 104 self.api_list_data_source_factory, |
104 self.intro_data_source_factory, | 105 self.intro_data_source_factory, |
105 self.samples_data_source_factory, | 106 self.samples_data_source_factory, |
106 self.sidenav_data_source_factory, | 107 self.sidenav_data_source_factory, |
107 self.compiled_host_fs_factory, | 108 self.compiled_host_fs_factory, |
108 self.ref_resolver_factory, | 109 self.ref_resolver_factory, |
109 svn_constants.PUBLIC_TEMPLATE_PATH, | 110 svn_constants.PUBLIC_TEMPLATE_PATH, |
110 svn_constants.PRIVATE_TEMPLATE_PATH, | 111 svn_constants.PRIVATE_TEMPLATE_PATH, |
111 static_path) | 112 base_path) |
112 | 113 |
113 self.example_zipper = ExampleZipper( | 114 self.example_zipper = ExampleZipper( |
114 self.compiled_host_fs_factory, | 115 self.compiled_host_fs_factory, |
115 svn_constants.DOCS_PATH) | 116 svn_constants.DOCS_PATH) |
116 | 117 |
117 self.path_canonicalizer = PathCanonicalizer( | 118 self.path_canonicalizer = PathCanonicalizer( |
118 channel, | 119 channel, |
119 self.compiled_host_fs_factory) | 120 self.compiled_host_fs_factory) |
120 | 121 |
121 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( | 122 self.content_cache = self.compiled_host_fs_factory.CreateIdentity( |
122 ServerInstance) | 123 ServerInstance) |
123 | 124 |
124 @staticmethod | 125 @staticmethod |
125 def ForTest(file_system): | 126 def ForTest(file_system): |
126 object_store_creator = ObjectStoreCreator.ForTest() | 127 object_store_creator = ObjectStoreCreator.ForTest() |
127 return ServerInstance('test', | 128 return ServerInstance('test', |
128 object_store_creator, | 129 object_store_creator, |
129 file_system, | 130 file_system, |
130 EmptyDirFileSystem(), | 131 EmptyDirFileSystem(), |
131 '/static', | 132 '', |
132 CompiledFileSystem.Factory(file_system, | 133 CompiledFileSystem.Factory(file_system, |
133 object_store_creator)) | 134 object_store_creator)) |
134 | 135 |
135 @staticmethod | 136 @staticmethod |
136 def ForLocal(): | 137 def ForLocal(): |
137 channel = 'trunk' | 138 channel = 'trunk' |
138 object_store_creator = ObjectStoreCreator(channel, | 139 object_store_creator = ObjectStoreCreator(channel, |
139 start_empty=False, | 140 start_empty=False, |
140 store_type=TestObjectStore) | 141 store_type=TestObjectStore) |
141 file_system = CachingFileSystem(LocalFileSystem.Create(), | 142 file_system = CachingFileSystem(LocalFileSystem.Create(), |
142 object_store_creator) | 143 object_store_creator) |
143 return ServerInstance( | 144 return ServerInstance( |
144 channel, | 145 channel, |
145 object_store_creator, | 146 object_store_creator, |
146 file_system, | 147 file_system, |
147 EmptyDirFileSystem(), | 148 EmptyDirFileSystem(), |
148 '/static', | 149 '', |
149 CompiledFileSystem.Factory(file_system, object_store_creator)) | 150 CompiledFileSystem.Factory(file_system, object_store_creator)) |
OLD | NEW |