Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/server_instance.py |
| =================================================================== |
| --- chrome/common/extensions/docs/server2/server_instance.py (revision 198562) |
| +++ chrome/common/extensions/docs/server2/server_instance.py (working copy) |
| @@ -24,8 +24,10 @@ |
| from local_file_system import LocalFileSystem |
| from object_store_creator import ObjectStoreCreator |
| from offline_file_system import OfflineFileSystem |
| +from patched_file_system import PatchedFileSystem |
| from path_canonicalizer import PathCanonicalizer |
| from reference_resolver import ReferenceResolver |
| +from rietveld_patcher import RietveldPatcher |
| from samples_data_source import SamplesDataSource |
| from sidenav_data_source import SidenavDataSource |
| from subversion_file_system import SubversionFileSystem |
| @@ -46,7 +48,7 @@ |
| @staticmethod |
| @memoize |
| - def GetOrCreateOffline(channel): |
| + def GetOrCreateOffline(channel, static_path=None, issue=None): |
|
not at google - send to devlin
2013/05/07 05:45:40
these optional parameters won't work well with the
|
| '''Gets/creates a local ServerInstance, meaning that only resources local to |
| the server - memcache, object store, etc, are queried. This amounts to not |
| setting up the subversion nor github file systems. |
| @@ -57,8 +59,9 @@ |
| branch) |
| # No svn nor github file systems. Rely on the crons to fill the caches, and |
| # for the caches to exist. |
| - return ServerInstance( |
| + return ServerInstance._CreateWithPatch( |
| channel, |
| + static_path, |
| object_store_creator_factory, |
| CachingFileSystem(OfflineFileSystem(SubversionFileSystem), |
| object_store_creator_factory, |
| @@ -67,10 +70,11 @@ |
| # CachingFileSystem so that it can be replaced with an |
| # OfflineFileSystem. Currently GFS doesn't set the child versions of |
| # stat requests so it doesn't. |
| - ServerInstance._GetOrCreateGithubFileSystem()) |
| + ServerInstance._GetOrCreateGithubFileSystem(), |
| + issue) |
| @staticmethod |
| - def CreateOnline(channel): |
| + def CreateOnline(channel, static_path=None, issue=None): |
| '''Creates/creates an online server instance, meaning that both local and |
| subversion/github resources are queried. |
| ''' |
| @@ -98,14 +102,56 @@ |
| AppEngineUrlFetcher(viewvc_url)), |
| object_store_creator_factory) |
| + return ServerInstance._CreateWithPatch( |
| + channel, |
| + static_path, |
| + object_store_creator_factory, |
| + svn_file_system, |
| + ServerInstance._GetOrCreateGithubFileSystem(), |
| + issue) |
| + |
| + @staticmethod |
| + def _CreateWithPatch(channel, |
| + static_path, |
| + object_store_creator_factory, |
| + svn_file_system, |
| + github_file_system, |
| + issue=None): |
| + if static_path is None: |
| + static_path = ('/static' if channel == 'stable' else |
| + '/%s/static' % channel) |
| + if issue is not None: |
| + original_object_store_creator_factory = object_store_creator_factory |
| + original_svn_file_system = svn_file_system |
| + object_store_creator_factory = ObjectStoreCreator.Factory( |
| + GetAppVersion(), |
| + 'trunk@%s' % issue) |
| + rietveld_patcher = RietveldPatcher( |
| + svn_constants.EXTENSIONS_PATH, |
| + issue, |
| + AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER), |
| + object_store_creator_factory) |
| + svn_file_system = PatchedFileSystem(svn_file_system, |
| + rietveld_patcher) |
| + compiled_fs_factory = CompiledFileSystem.Factory( |
| + original_svn_file_system, |
| + original_object_store_creator_factory, |
| + svn_file_system, |
| + object_store_creator_factory) |
| + else: |
| + compiled_fs_factory = None |
| + |
| return ServerInstance(channel, |
| + static_path, |
| object_store_creator_factory, |
| svn_file_system, |
| - ServerInstance._GetOrCreateGithubFileSystem()) |
| + github_file_system, |
| + compiled_fs_factory) |
| @staticmethod |
| def CreateForTest(file_system): |
| return ServerInstance('test', |
| + '/static', |
| ObjectStoreCreator.TestFactory(), |
| file_system, |
| None) |
| @@ -133,16 +179,21 @@ |
| def __init__(self, |
| channel, |
| + static_path, |
| object_store_creator_factory, |
| svn_file_system, |
| - github_file_system): |
| + github_file_system, |
| + compiled_fs_factory=None): |
| self.svn_file_system = svn_file_system |
| self.github_file_system = github_file_system |
| - self.compiled_fs_factory = CompiledFileSystem.Factory( |
| - svn_file_system, |
| - object_store_creator_factory) |
| + if compiled_fs_factory is None: |
| + self.compiled_fs_factory = CompiledFileSystem.Factory( |
| + svn_file_system, |
| + object_store_creator_factory) |
| + else: |
| + self.compiled_fs_factory = compiled_fs_factory |
| self.api_list_data_source_factory = APIListDataSource.Factory( |
| self.compiled_fs_factory, |
| @@ -198,7 +249,8 @@ |
| self.compiled_fs_factory, |
| self.ref_resolver_factory, |
| svn_constants.PUBLIC_TEMPLATE_PATH, |
| - svn_constants.PRIVATE_TEMPLATE_PATH) |
| + svn_constants.PRIVATE_TEMPLATE_PATH, |
| + static_path) |
| self.example_zipper = ExampleZipper( |
| self.compiled_fs_factory, |