| 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 fnmatch import fnmatch | 5 from fnmatch import fnmatch |
| 6 import logging | 6 import logging |
| 7 from urlparse import urlparse | 7 from urlparse import urlparse |
| 8 | 8 |
| 9 from appengine_url_fetcher import AppEngineUrlFetcher | 9 from appengine_url_fetcher import AppEngineUrlFetcher |
| 10 from caching_file_system import CachingFileSystem | 10 from caching_file_system import CachingFileSystem |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 # impossible to add files in the patches. | 53 # impossible to add files in the patches. |
| 54 offline=False, | 54 offline=False, |
| 55 # The trunk file system for this creator should be the patched one. | 55 # The trunk file system for this creator should be the patched one. |
| 56 default_trunk_instance=patched_file_system)) | 56 default_trunk_instance=patched_file_system)) |
| 57 | 57 |
| 58 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory( | 58 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory( |
| 59 [unpatched_file_system], object_store_creator) | 59 [unpatched_file_system], object_store_creator) |
| 60 | 60 |
| 61 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) | 61 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) |
| 62 | 62 |
| 63 return ServerInstance(object_store_creator, | 63 server_instance = ServerInstance( |
| 64 combined_compiled_fs_factory, | 64 object_store_creator, |
| 65 branch_utility, | 65 combined_compiled_fs_factory, |
| 66 patched_host_file_system_provider, | 66 branch_utility, |
| 67 self._delegate.CreateGithubFileSystemProvider( | 67 patched_host_file_system_provider, |
| 68 object_store_creator), | 68 self._delegate.CreateGithubFileSystemProvider(object_store_creator), |
| 69 base_path='/_patch/%s/' % self._issue) | 69 base_path='/_patch/%s/' % self._issue) |
| 70 |
| 71 # HACK: if content_providers.json changes in this patch then the cron needs |
| 72 # to be re-run to pull in the new configuration. |
| 73 _, _, modified = rietveld_patcher.GetPatchedFiles() |
| 74 if svn_constants.CONTENT_PROVIDERS_PATH in modified: |
| 75 server_instance.content_providers.Cron().Get() |
| 76 |
| 77 return server_instance |
| 70 | 78 |
| 71 class PatchServlet(Servlet): | 79 class PatchServlet(Servlet): |
| 72 '''Servlet which renders patched docs. | 80 '''Servlet which renders patched docs. |
| 73 ''' | 81 ''' |
| 74 def __init__(self, request, delegate=None): | 82 def __init__(self, request, delegate=None): |
| 75 self._request = request | 83 self._request = request |
| 76 self._delegate = delegate or InstanceServlet.Delegate() | 84 self._delegate = delegate or InstanceServlet.Delegate() |
| 77 | 85 |
| 78 def Get(self): | 86 def Get(self): |
| 79 if (not IsDevServer() and | 87 if (not IsDevServer() and |
| (...skipping 22 matching lines...) Expand all Loading... |
| 102 # Disable cache for patched content. | 110 # Disable cache for patched content. |
| 103 response.headers.pop('cache-control', None) | 111 response.headers.pop('cache-control', None) |
| 104 except RietveldPatcherError as e: | 112 except RietveldPatcherError as e: |
| 105 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) | 113 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) |
| 106 | 114 |
| 107 redirect_url, permanent = response.GetRedirect() | 115 redirect_url, permanent = response.GetRedirect() |
| 108 if redirect_url is not None: | 116 if redirect_url is not None: |
| 109 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), | 117 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), |
| 110 permanent) | 118 permanent) |
| 111 return response | 119 return response |
| OLD | NEW |