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_rietveld_patcher import CachingRietveldPatcher | 10 from caching_rietveld_patcher import CachingRietveldPatcher |
(...skipping 11 matching lines...) Expand all Loading... |
22 from gcs_file_system_provider import CloudStorageFileSystemProvider | 22 from gcs_file_system_provider import CloudStorageFileSystemProvider |
23 | 23 |
24 | 24 |
25 class _PatchServletDelegate(RenderServlet.Delegate): | 25 class _PatchServletDelegate(RenderServlet.Delegate): |
26 def __init__(self, issue, delegate): | 26 def __init__(self, issue, delegate): |
27 self._issue = issue | 27 self._issue = issue |
28 self._delegate = delegate | 28 self._delegate = delegate |
29 | 29 |
30 def CreateServerInstance(self): | 30 def CreateServerInstance(self): |
31 # start_empty=False because a patch can rely on files that are already in | 31 # start_empty=False because a patch can rely on files that are already in |
32 # SVN repository but not yet pulled into data store by cron jobs (a typical | 32 # the Git repository but not yet pulled into data store by cron jobs (a |
33 # example is to add documentation for an existing API). | 33 # typical example is to add documentation for an existing API). |
34 object_store_creator = ObjectStoreCreator(start_empty=False) | 34 object_store_creator = ObjectStoreCreator(start_empty=False) |
35 | 35 |
36 unpatched_file_system = self._delegate.CreateHostFileSystemProvider( | 36 unpatched_file_system = self._delegate.CreateHostFileSystemProvider( |
37 object_store_creator).GetMaster() | 37 object_store_creator).GetMaster() |
38 | 38 |
39 rietveld_patcher = CachingRietveldPatcher( | 39 rietveld_patcher = CachingRietveldPatcher( |
40 RietveldPatcher(self._issue, | 40 RietveldPatcher(self._issue, |
41 AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)), | 41 AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)), |
42 object_store_creator) | 42 object_store_creator) |
43 | 43 |
(...skipping 20 matching lines...) Expand all Loading... |
64 branch_utility, | 64 branch_utility, |
65 patched_host_file_system_provider, | 65 patched_host_file_system_provider, |
66 self._delegate.CreateGithubFileSystemProvider(object_store_creator), | 66 self._delegate.CreateGithubFileSystemProvider(object_store_creator), |
67 CloudStorageFileSystemProvider(object_store_creator), | 67 CloudStorageFileSystemProvider(object_store_creator), |
68 base_path='/_patch/%s/' % self._issue) | 68 base_path='/_patch/%s/' % self._issue) |
69 | 69 |
70 # HACK: if content_providers.json changes in this patch then the cron needs | 70 # HACK: if content_providers.json changes in this patch then the cron needs |
71 # to be re-run to pull in the new configuration. | 71 # to be re-run to pull in the new configuration. |
72 _, _, modified = rietveld_patcher.GetPatchedFiles() | 72 _, _, modified = rietveld_patcher.GetPatchedFiles() |
73 if CONTENT_PROVIDERS in modified: | 73 if CONTENT_PROVIDERS in modified: |
74 server_instance.content_providers.Cron().Get() | 74 server_instance.content_providers.Refresh().Get() |
75 | 75 |
76 return server_instance | 76 return server_instance |
77 | 77 |
78 class PatchServlet(Servlet): | 78 class PatchServlet(Servlet): |
79 '''Servlet which renders patched docs. | 79 '''Servlet which renders patched docs. |
80 ''' | 80 ''' |
81 def __init__(self, request, delegate=None): | 81 def __init__(self, request, delegate=None): |
82 self._request = request | 82 self._request = request |
83 self._delegate = delegate or InstanceServlet.Delegate() | 83 self._delegate = delegate or InstanceServlet.Delegate() |
84 | 84 |
(...skipping 24 matching lines...) Expand all Loading... |
109 # Disable cache for patched content. | 109 # Disable cache for patched content. |
110 response.headers.pop('cache-control', None) | 110 response.headers.pop('cache-control', None) |
111 except RietveldPatcherError as e: | 111 except RietveldPatcherError as e: |
112 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) | 112 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) |
113 | 113 |
114 redirect_url, permanent = response.GetRedirect() | 114 redirect_url, permanent = response.GetRedirect() |
115 if redirect_url is not None: | 115 if redirect_url is not None: |
116 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), | 116 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), |
117 permanent) | 117 permanent) |
118 return response | 118 return response |
OLD | NEW |