| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 appengine_wrappers import IsDevServer | 5 from appengine_wrappers import IsDevServer |
| 6 from branch_utility import BranchUtility | 6 from branch_utility import BranchUtility |
| 7 from compiled_file_system import CompiledFileSystem | 7 from compiled_file_system import CompiledFileSystem |
| 8 from empty_dir_file_system import EmptyDirFileSystem | 8 from empty_dir_file_system import EmptyDirFileSystem |
| 9 from github_file_system import GithubFileSystem | 9 from github_file_system import GithubFileSystem |
| 10 from host_file_system_creator import HostFileSystemCreator | 10 from host_file_system_creator import HostFileSystemCreator |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 Anyway - to enforce this, we actually don't give instances access to SVN. If | 25 Anyway - to enforce this, we actually don't give instances access to SVN. If |
| 26 anything is missing from datastore, it'll be a 404. If the cronjobs don't | 26 anything is missing from datastore, it'll be a 404. If the cronjobs don't |
| 27 manage to catch everything - uhoh. On the other hand, we'll figure it out | 27 manage to catch everything - uhoh. On the other hand, we'll figure it out |
| 28 pretty soon, and it also means that legitimate 404s are caught before a round | 28 pretty soon, and it also means that legitimate 404s are caught before a round |
| 29 trip to SVN. | 29 trip to SVN. |
| 30 ''' | 30 ''' |
| 31 def __init__(self, delegate): | 31 def __init__(self, delegate): |
| 32 self._delegate = delegate | 32 self._delegate = delegate |
| 33 | 33 |
| 34 @memoize | 34 @memoize |
| 35 def CreateServerInstanceForChannel(self, channel): | 35 def CreateServerInstance(self): |
| 36 object_store_creator = ObjectStoreCreator(channel, start_empty=False) | 36 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 37 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) | 37 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) |
| 38 host_file_system_creator = self._delegate.CreateHostFileSystemCreator( | 38 host_file_system_creator = self._delegate.CreateHostFileSystemCreator( |
| 39 object_store_creator) | 39 object_store_creator) |
| 40 host_file_system = host_file_system_creator.Create( | 40 host_file_system = host_file_system_creator.Create() |
| 41 branch_utility.GetChannelInfo(channel).branch) | |
| 42 app_samples_file_system = self._delegate.CreateAppSamplesFileSystem( | 41 app_samples_file_system = self._delegate.CreateAppSamplesFileSystem( |
| 43 object_store_creator) | 42 object_store_creator) |
| 44 compiled_host_fs_factory = CompiledFileSystem.Factory( | 43 compiled_host_fs_factory = CompiledFileSystem.Factory( |
| 45 host_file_system, | 44 host_file_system, |
| 46 object_store_creator) | 45 object_store_creator) |
| 47 return ServerInstance(channel, | 46 return ServerInstance(object_store_creator, |
| 48 object_store_creator, | |
| 49 host_file_system, | 47 host_file_system, |
| 50 app_samples_file_system, | 48 app_samples_file_system, |
| 51 '' if channel == 'stable' else '/%s' % channel, | 49 '', |
| 52 compiled_host_fs_factory, | 50 compiled_host_fs_factory, |
| 53 branch_utility, | 51 branch_utility, |
| 54 host_file_system_creator) | 52 host_file_system_creator) |
| 55 | 53 |
| 56 class InstanceServlet(object): | 54 class InstanceServlet(object): |
| 57 '''Servlet for running on normal AppEngine instances. | 55 '''Servlet for running on normal AppEngine instances. |
| 58 Create this via GetConstructor() so that cache state can be shared amongst | 56 Create this via GetConstructor() so that cache state can be shared amongst |
| 59 them via the memoizing Delegate. | 57 them via the memoizing Delegate. |
| 60 ''' | 58 ''' |
| 61 class Delegate(object): | 59 class Delegate(object): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 GithubFileSystem.Create(object_store_creator)) | 72 GithubFileSystem.Create(object_store_creator)) |
| 75 | 73 |
| 76 @staticmethod | 74 @staticmethod |
| 77 def GetConstructor(delegate_for_test=None): | 75 def GetConstructor(delegate_for_test=None): |
| 78 render_servlet_delegate = _OfflineRenderServletDelegate( | 76 render_servlet_delegate = _OfflineRenderServletDelegate( |
| 79 delegate_for_test or InstanceServlet.Delegate()) | 77 delegate_for_test or InstanceServlet.Delegate()) |
| 80 return lambda request: RenderServlet(request, render_servlet_delegate) | 78 return lambda request: RenderServlet(request, render_servlet_delegate) |
| 81 | 79 |
| 82 # NOTE: if this were a real Servlet it would implement a Get() method, but | 80 # NOTE: if this were a real Servlet it would implement a Get() method, but |
| 83 # GetConstructor returns an appropriate lambda function (Request -> Servlet). | 81 # GetConstructor returns an appropriate lambda function (Request -> Servlet). |
| OLD | NEW |