Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/common/extensions/docs/server2/patch_servlet.py

Issue 1151283007: Docserver overhaul: Gitiles away from me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove inform_users template to fix presubmit failure (it's now a redirect) Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 7
8 from appengine_url_fetcher import AppEngineUrlFetcher
9 from caching_rietveld_patcher import CachingRietveldPatcher 8 from caching_rietveld_patcher import CachingRietveldPatcher
10 from chained_compiled_file_system import ChainedCompiledFileSystem 9 from chained_compiled_file_system import ChainedCompiledFileSystem
11 from environment import IsDevServer 10 from environment import IsDevServer
11 from environment_wrappers import CreateUrlFetcher
12 from extensions_paths import CONTENT_PROVIDERS 12 from extensions_paths import CONTENT_PROVIDERS
13 from instance_servlet import InstanceServlet 13 from instance_servlet import InstanceServlet
14 from render_servlet import RenderServlet 14 from render_servlet import RenderServlet
15 from rietveld_patcher import RietveldPatcher, RietveldPatcherError 15 from rietveld_patcher import RietveldPatcher, RietveldPatcherError
16 from object_store_creator import ObjectStoreCreator 16 from object_store_creator import ObjectStoreCreator
17 from patched_file_system import PatchedFileSystem 17 from patched_file_system import PatchedFileSystem
18 from server_instance import ServerInstance 18 from server_instance import ServerInstance
19 from servlet import Request, Response, Servlet 19 from servlet import Request, Response, Servlet
20 import url_constants 20 import url_constants
21 from gcs_file_system_provider import CloudStorageFileSystemProvider 21 from gcs_file_system_provider import CloudStorageFileSystemProvider
22 22
23 23
24 class _PatchServletDelegate(RenderServlet.Delegate): 24 class _PatchServletDelegate(RenderServlet.Delegate):
25 def __init__(self, issue, delegate): 25 def __init__(self, issue, delegate):
26 self._issue = issue 26 self._issue = issue
27 self._delegate = delegate 27 self._delegate = delegate
28 28
29 def CreateServerInstance(self): 29 def CreateServerInstance(self):
30 # start_empty=False because a patch can rely on files that are already in 30 # start_empty=False because a patch can rely on files that are already in
31 # the Git repository but not yet pulled into data store by cron jobs (a 31 # the Git repository but not yet pulled into data store by cron jobs (a
32 # typical example is to add documentation for an existing API). 32 # typical example is to add documentation for an existing API).
33 object_store_creator = ObjectStoreCreator(start_empty=False) 33 object_store_creator = ObjectStoreCreator(start_empty=False)
34 34
35 unpatched_file_system = self._delegate.CreateHostFileSystemProvider( 35 unpatched_file_system = self._delegate.CreateHostFileSystemProvider(
36 object_store_creator).GetMaster() 36 object_store_creator).GetMaster()
37 37
38 rietveld_patcher = CachingRietveldPatcher( 38 rietveld_patcher = CachingRietveldPatcher(
39 RietveldPatcher(self._issue, 39 RietveldPatcher(self._issue,
40 AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)), 40 CreateUrlFetcher(url_constants.CODEREVIEW_SERVER)),
41 object_store_creator) 41 object_store_creator)
42 42
43 patched_file_system = PatchedFileSystem(unpatched_file_system, 43 patched_file_system = PatchedFileSystem(unpatched_file_system,
44 rietveld_patcher) 44 rietveld_patcher)
45 45
46 patched_host_file_system_provider = ( 46 patched_host_file_system_provider = (
47 self._delegate.CreateHostFileSystemProvider( 47 self._delegate.CreateHostFileSystemProvider(
48 object_store_creator, 48 object_store_creator,
49 # The patched file system needs to be online otherwise it'd be 49 # The patched file system needs to be online otherwise it'd be
50 # impossible to add files in the patches. 50 # impossible to add files in the patches.
51 offline=False, 51 offline=False,
52 # The master file system for this creator should be the patched one. 52 # The master file system for this creator should be the patched one.
53 default_master_instance=patched_file_system)) 53 default_master_instance=patched_file_system))
54 54
55 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory( 55 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory(
56 [unpatched_file_system], object_store_creator) 56 [unpatched_file_system], object_store_creator)
57 57
58 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) 58 branch_utility = self._delegate.CreateBranchUtility(object_store_creator)
59 59
60 server_instance = ServerInstance( 60 server_instance = ServerInstance(
61 object_store_creator, 61 object_store_creator,
62 combined_compiled_fs_factory, 62 combined_compiled_fs_factory,
63 branch_utility, 63 branch_utility,
64 patched_host_file_system_provider, 64 patched_host_file_system_provider,
65 self._delegate.CreateGithubFileSystemProvider(object_store_creator),
66 CloudStorageFileSystemProvider(object_store_creator), 65 CloudStorageFileSystemProvider(object_store_creator),
67 base_path='/_patch/%s/' % self._issue) 66 base_path='/_patch/%s/' % self._issue)
68 67
69 # HACK: if content_providers.json changes in this patch then the cron needs 68 # HACK: if content_providers.json changes in this patch then the cron needs
70 # to be re-run to pull in the new configuration. 69 # to be re-run to pull in the new configuration.
71 _, _, modified = rietveld_patcher.GetPatchedFiles() 70 _, _, modified = rietveld_patcher.GetPatchedFiles()
72 if CONTENT_PROVIDERS in modified: 71 if CONTENT_PROVIDERS in modified:
73 server_instance.content_providers.Refresh().Get() 72 server_instance.content_providers.Refresh().Get()
74 73
75 return server_instance 74 return server_instance
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 # Disable cache for patched content. 107 # Disable cache for patched content.
109 response.headers.pop('cache-control', None) 108 response.headers.pop('cache-control', None)
110 except RietveldPatcherError as e: 109 except RietveldPatcherError as e:
111 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) 110 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'})
112 111
113 redirect_url, permanent = response.GetRedirect() 112 redirect_url, permanent = response.GetRedirect()
114 if redirect_url is not None: 113 if redirect_url is not None:
115 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), 114 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url),
116 permanent) 115 permanent)
117 return response 116 return response
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698