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

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

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes Created 7 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 import mimetypes 7 import mimetypes
8 import traceback 8 import traceback
9 import os 9 import os
10 10
11 from api_data_source import APIDataSource 11 from api_data_source import APIDataSource
12 from api_list_data_source import APIListDataSource 12 from api_list_data_source import APIListDataSource
13 from appengine_blobstore import AppEngineBlobstore 13 from appengine_blobstore import AppEngineBlobstore
14 from appengine_url_fetcher import AppEngineUrlFetcher 14 from appengine_url_fetcher import AppEngineUrlFetcher
15 from appengine_wrappers import GetAppVersion, IsDevServer 15 from appengine_wrappers import GetAppVersion, IsDevServer
16 from availability_data_source import AvailabilityDataSource
16 from branch_utility import BranchUtility 17 from branch_utility import BranchUtility
17 from caching_file_system import CachingFileSystem 18 from caching_file_system import CachingFileSystem
19 from chrome_version_utility import ChromeVersionUtility
18 from compiled_file_system import CompiledFileSystem 20 from compiled_file_system import CompiledFileSystem
19 from empty_dir_file_system import EmptyDirFileSystem 21 from empty_dir_file_system import EmptyDirFileSystem
20 from example_zipper import ExampleZipper 22 from example_zipper import ExampleZipper
21 from file_system import FileNotFoundError 23 from file_system import FileNotFoundError
22 from github_file_system import GithubFileSystem 24 from github_file_system import GithubFileSystem
23 from intro_data_source import IntroDataSource 25 from intro_data_source import IntroDataSource
24 from local_file_system import LocalFileSystem 26 from local_file_system import LocalFileSystem
25 from object_store_creator import ObjectStoreCreator 27 from object_store_creator import ObjectStoreCreator
26 from offline_file_system import OfflineFileSystem 28 from offline_file_system import OfflineFileSystem
27 from path_canonicalizer import PathCanonicalizer 29 from path_canonicalizer import PathCanonicalizer
(...skipping 21 matching lines...) Expand all
49 github_file_system = None 51 github_file_system = None
50 52
51 @staticmethod 53 @staticmethod
52 @memoize 54 @memoize
53 def GetOrCreateOffline(channel): 55 def GetOrCreateOffline(channel):
54 '''Gets/creates a local ServerInstance, meaning that only resources local to 56 '''Gets/creates a local ServerInstance, meaning that only resources local to
55 the server - memcache, object store, etc, are queried. This amounts to not 57 the server - memcache, object store, etc, are queried. This amounts to not
56 setting up the subversion nor github file systems. 58 setting up the subversion nor github file systems.
57 ''' 59 '''
58 branch_utility = ServerInstance._GetOrCreateBranchUtility() 60 branch_utility = ServerInstance._GetOrCreateBranchUtility()
59 branch = branch_utility.GetBranchNumberForChannelName(channel) 61 branch = branch_utility.GetChannelInfoForChannelName(channel).branch
60 object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(), 62 object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(),
61 branch) 63 branch)
62 # No svn nor github file systems. Rely on the crons to fill the caches, and 64 # No svn nor github file systems. Rely on the crons to fill the caches, and
63 # for the caches to exist. 65 # for the caches to exist.
64 return ServerInstance( 66 return ServerInstance(
65 channel, 67 channel,
66 object_store_creator_factory, 68 object_store_creator_factory,
67 CachingFileSystem(OfflineFileSystem(SubversionFileSystem), 69 CachingFileSystem(OfflineFileSystem(SubversionFileSystem),
68 object_store_creator_factory), 70 object_store_creator_factory),
69 # TODO(kalman): convert GithubFileSystem to be wrappable in a 71 # TODO(kalman): convert GithubFileSystem to be wrappable in a
70 # CachingFileSystem so that it can be replaced with an 72 # CachingFileSystem so that it can be replaced with an
71 # OfflineFileSystem. Currently GFS doesn't set the child versions of 73 # OfflineFileSystem. Currently GFS doesn't set the child versions of
72 # stat requests so it doesn't. 74 # stat requests so it doesn't.
73 ServerInstance._GetOrCreateGithubFileSystem()) 75 ServerInstance._GetOrCreateGithubFileSystem())
74 76
75 @staticmethod 77 @staticmethod
76 def CreateOnline(channel): 78 def CreateOnline(channel):
77 '''Creates/creates an online server instance, meaning that both local and 79 '''Creates/creates an online server instance, meaning that both local and
78 subversion/github resources are queried. 80 subversion/github resources are queried.
79 ''' 81 '''
80 branch_utility = ServerInstance._GetOrCreateBranchUtility() 82 branch_utility = ServerInstance._GetOrCreateBranchUtility()
81 branch = branch_utility.GetBranchNumberForChannelName(channel) 83 branch = branch_utility.GetChannelInfoForChannelName(channel).branch
82 84
83 if branch == 'trunk': 85 if branch == 'trunk':
84 svn_url = '/'.join((url_constants.SVN_TRUNK_URL, 86 svn_url = '/'.join((url_constants.SVN_TRUNK_URL,
85 'src', 87 'src',
86 svn_constants.EXTENSIONS_PATH)) 88 svn_constants.EXTENSIONS_PATH))
87 else: 89 else:
88 svn_url = '/'.join((url_constants.SVN_BRANCH_URL, 90 svn_url = '/'.join((url_constants.SVN_BRANCH_URL,
89 branch, 91 branch,
90 'src', 92 'src',
91 svn_constants.EXTENSIONS_PATH)) 93 svn_constants.EXTENSIONS_PATH))
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 svn_file_system, 143 svn_file_system,
142 github_file_system): 144 github_file_system):
143 self.svn_file_system = svn_file_system 145 self.svn_file_system = svn_file_system
144 146
145 self.github_file_system = github_file_system 147 self.github_file_system = github_file_system
146 148
147 self.compiled_fs_factory = CompiledFileSystem.Factory( 149 self.compiled_fs_factory = CompiledFileSystem.Factory(
148 svn_file_system, 150 svn_file_system,
149 object_store_creator_factory) 151 object_store_creator_factory)
150 152
153 self.chrome_version_utility = ChromeVersionUtility(
154 url_constants.OMAHA_DEV_HISTORY,
155 AppEngineUrlFetcher(None),
156 object_store_creator_factory)
157
158 self.availability_data_source_factory = AvailabilityDataSource.Factory(
159 self.chrome_version_utility,
160 object_store_creator_factory,
161 svn_file_system)
not at google - send to devlin 2013/04/30 18:34:19 I think we need to pass in a special trunk svn fil
epeterson 2013/05/13 02:38:10 Definitely, thanks for catching that.
162
151 self.api_list_data_source_factory = APIListDataSource.Factory( 163 self.api_list_data_source_factory = APIListDataSource.Factory(
152 self.compiled_fs_factory, 164 self.compiled_fs_factory,
153 svn_constants.API_PATH, 165 svn_constants.API_PATH,
154 svn_constants.PUBLIC_TEMPLATE_PATH) 166 svn_constants.PUBLIC_TEMPLATE_PATH)
155 167
156 self.api_data_source_factory = APIDataSource.Factory( 168 self.api_data_source_factory = APIDataSource.Factory(
157 self.compiled_fs_factory, 169 self.compiled_fs_factory,
158 svn_constants.API_PATH) 170 svn_constants.API_PATH,
171 self.availability_data_source_factory,
172 svn_file_system)
159 173
160 self.ref_resolver_factory = ReferenceResolver.Factory( 174 self.ref_resolver_factory = ReferenceResolver.Factory(
161 self.api_data_source_factory, 175 self.api_data_source_factory,
162 self.api_list_data_source_factory, 176 self.api_list_data_source_factory,
163 object_store_creator_factory) 177 object_store_creator_factory)
164 178
165 self.api_data_source_factory.SetReferenceResolverFactory( 179 self.api_data_source_factory.SetReferenceResolverFactory(
166 self.ref_resolver_factory) 180 self.ref_resolver_factory)
167 181
168 # Note: samples are super slow in the dev server because it doesn't support 182 # Note: samples are super slow in the dev server because it doesn't support
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 262
249 response.headers['x-frame-options'] = 'sameorigin' 263 response.headers['x-frame-options'] = 'sameorigin'
250 if content is None: 264 if content is None:
251 response.set_status(404); 265 response.set_status(404);
252 response.out.write(templates.Render('404')) 266 response.out.write(templates.Render('404'))
253 else: 267 else:
254 if not content: 268 if not content:
255 logging.error('%s had empty content' % path) 269 logging.error('%s had empty content' % path)
256 response.headers['cache-control'] = 'max-age=300' 270 response.headers['cache-control'] = 'max-age=300'
257 response.out.write(content) 271 response.out.write(content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698