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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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 | Annotate | Revision Log
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 os 8 import os
9 9
10 from api_data_source import APIDataSource 10 from api_data_source import APIDataSource
11 from api_list_data_source import APIListDataSource 11 from api_list_data_source import APIListDataSource
12 from appengine_blobstore import AppEngineBlobstore 12 from appengine_blobstore import AppEngineBlobstore
13 from appengine_url_fetcher import AppEngineUrlFetcher 13 from appengine_url_fetcher import AppEngineUrlFetcher
14 from appengine_wrappers import GetAppVersion
14 from branch_utility import BranchUtility 15 from branch_utility import BranchUtility
15 from caching_file_system import CachingFileSystem 16 from caching_file_system import CachingFileSystem
16 from compiled_file_system import CompiledFileSystem 17 from compiled_file_system import CompiledFileSystem
17 from example_zipper import ExampleZipper 18 from example_zipper import ExampleZipper
18 from file_system import FileNotFoundError 19 from file_system import FileNotFoundError
19 from github_file_system import GithubFileSystem 20 from github_file_system import GithubFileSystem
20 from intro_data_source import IntroDataSource 21 from intro_data_source import IntroDataSource
21 from local_file_system import LocalFileSystem 22 from local_file_system import LocalFileSystem
22 from object_store_creator import ObjectStoreCreator 23 from object_store_creator import ObjectStoreCreator
23 from offline_file_system import OfflineFileSystem 24 from offline_file_system import OfflineFileSystem
(...skipping 20 matching lines...) Expand all
44 45
45 @staticmethod 46 @staticmethod
46 @memoize 47 @memoize
47 def GetOrCreateOffline(channel): 48 def GetOrCreateOffline(channel):
48 '''Gets/creates a local ServerInstance, meaning that only resources local to 49 '''Gets/creates a local ServerInstance, meaning that only resources local to
49 the server - memcache, object store, etc, are queried. This amounts to not 50 the server - memcache, object store, etc, are queried. This amounts to not
50 setting up the subversion nor github file systems. 51 setting up the subversion nor github file systems.
51 ''' 52 '''
52 branch_utility = ServerInstance._GetOrCreateBranchUtility() 53 branch_utility = ServerInstance._GetOrCreateBranchUtility()
53 branch = branch_utility.GetBranchNumberForChannelName(channel) 54 branch = branch_utility.GetBranchNumberForChannelName(channel)
54 object_store_creator_factory = ObjectStoreCreator.Factory(branch) 55 object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(),
56 branch)
55 # No svn nor github file systems. Rely on the crons to fill the caches, and 57 # No svn nor github file systems. Rely on the crons to fill the caches, and
56 # for the caches to exist. 58 # for the caches to exist.
57 return ServerInstance( 59 return ServerInstance(
58 channel, 60 channel,
59 object_store_creator_factory, 61 object_store_creator_factory,
60 CachingFileSystem(OfflineFileSystem(SubversionFileSystem), 62 CachingFileSystem(OfflineFileSystem(SubversionFileSystem),
61 object_store_creator_factory), 63 object_store_creator_factory),
62 # TODO(kalman): convert GithubFileSystem to be wrappable in a 64 # TODO(kalman): convert GithubFileSystem to be wrappable in a
63 # CachingFileSystem so that it can be replaced with an 65 # CachingFileSystem so that it can be replaced with an
64 # OfflineFileSystem. Currently GFS doesn't set the child versions of 66 # OfflineFileSystem. Currently GFS doesn't set the child versions of
(...skipping 15 matching lines...) Expand all
80 svn_constants.EXTENSIONS_PATH)) 82 svn_constants.EXTENSIONS_PATH))
81 else: 83 else:
82 svn_url = '/'.join((url_constants.SVN_BRANCH_URL, 84 svn_url = '/'.join((url_constants.SVN_BRANCH_URL,
83 branch, 85 branch,
84 'src', 86 'src',
85 svn_constants.EXTENSIONS_PATH)) 87 svn_constants.EXTENSIONS_PATH))
86 88
87 viewvc_url = svn_url.replace(url_constants.SVN_URL, 89 viewvc_url = svn_url.replace(url_constants.SVN_URL,
88 url_constants.VIEWVC_URL) 90 url_constants.VIEWVC_URL)
89 91
90 object_store_creator_factory = ObjectStoreCreator.Factory(branch) 92 object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(),
93 branch)
91 94
92 svn_file_system = CachingFileSystem( 95 svn_file_system = CachingFileSystem(
93 SubversionFileSystem(AppEngineUrlFetcher(svn_url), 96 SubversionFileSystem(AppEngineUrlFetcher(svn_url),
94 AppEngineUrlFetcher(viewvc_url)), 97 AppEngineUrlFetcher(viewvc_url)),
95 object_store_creator_factory) 98 object_store_creator_factory)
96 99
97 return ServerInstance(channel, 100 return ServerInstance(channel,
98 object_store_creator_factory, 101 object_store_creator_factory,
99 svn_file_system, 102 svn_file_system,
100 ServerInstance._GetOrCreateGithubFileSystem()) 103 ServerInstance._GetOrCreateGithubFileSystem())
101 104
102 @staticmethod 105 @staticmethod
103 def CreateForTest(file_system): 106 def CreateForTest(file_system):
104 return ServerInstance('test', 107 return ServerInstance('test',
105 ObjectStoreCreator.Factory('test'), 108 ObjectStoreCreator.TestFactory(),
106 file_system, 109 file_system,
107 None) 110 None)
108 111
109 @staticmethod 112 @staticmethod
110 def _GetOrCreateBranchUtility(): 113 def _GetOrCreateBranchUtility():
111 if ServerInstance.branch_utility is None: 114 if ServerInstance.branch_utility is None:
112 ServerInstance.branch_utility = BranchUtility( 115 ServerInstance.branch_utility = BranchUtility(
113 url_constants.OMAHA_PROXY_URL, 116 url_constants.OMAHA_PROXY_URL,
114 AppEngineUrlFetcher()) 117 AppEngineUrlFetcher())
115 return ServerInstance.branch_utility 118 return ServerInstance.branch_utility
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 231
229 response.headers['x-frame-options'] = 'sameorigin' 232 response.headers['x-frame-options'] = 'sameorigin'
230 if content is None: 233 if content is None:
231 response.set_status(404); 234 response.set_status(404);
232 response.out.write(templates.Render('404')) 235 response.out.write(templates.Render('404'))
233 else: 236 else:
234 if not content: 237 if not content:
235 logging.error('%s had empty content' % path) 238 logging.error('%s had empty content' % path)
236 response.headers['cache-control'] = 'max-age=300' 239 response.headers['cache-control'] = 'max-age=300'
237 response.out.write(content) 240 response.out.write(content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698