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

Side by Side Diff: chrome/common/extensions/docs/server2/instance_servlet.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: Revisions, Offline/Online Access (bypassed-hooks) 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 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 appengine_wrappers import IsDevServer 5 from appengine_wrappers import IsDevServer
6 from branch_utility import BranchUtility 6 from branch_utility import BranchUtility
7 from caching_file_system import CachingFileSystem 7 from caching_file_system import CachingFileSystem
8 from empty_dir_file_system import EmptyDirFileSystem 8 from empty_dir_file_system import EmptyDirFileSystem
9 from github_file_system import GithubFileSystem 9 from github_file_system import GithubFileSystem
10 from third_party.json_schema_compiler.memoize import memoize 10 from third_party.json_schema_compiler.memoize import memoize
(...skipping 19 matching lines...) Expand all
30 pretty soon, and it also means that legitimate 404s are caught before a round 30 pretty soon, and it also means that legitimate 404s are caught before a round
31 trip to SVN. 31 trip to SVN.
32 ''' 32 '''
33 def __init__(self, delegate): 33 def __init__(self, delegate):
34 self._delegate = delegate 34 self._delegate = delegate
35 35
36 @memoize 36 @memoize
37 def CreateServerInstanceForChannel(self, channel): 37 def CreateServerInstanceForChannel(self, channel):
38 object_store_creator = ObjectStoreCreator(channel, start_empty=False) 38 object_store_creator = ObjectStoreCreator(channel, start_empty=False)
39 branch = (self._delegate.CreateBranchUtility(object_store_creator) 39 branch = (self._delegate.CreateBranchUtility(object_store_creator)
40 .GetBranchForChannel(channel)) 40 .GetChannelInfo(channel).branch)
41 host_file_system = CachingFileSystem( 41 host_file_system = CachingFileSystem(
42 OfflineFileSystem(self._delegate.CreateHostFileSystemForBranch(branch)), 42 OfflineFileSystem(self._delegate.CreateHostFileSystemForBranch(branch)),
43 object_store_creator) 43 object_store_creator)
44 app_samples_file_system = self._delegate.CreateAppSamplesFileSystem( 44 app_samples_file_system = self._delegate.CreateAppSamplesFileSystem(
45 object_store_creator) 45 object_store_creator)
46 def create_file_system(branch):
47 object_store_creator = ObjectStoreCreator(branch, start_empty=False)
48 return CachingFileSystem(
49 OfflineFileSystem(SubversionFileSystem.Create(branch)),
50 object_store_creator)
46 return ServerInstance(channel, 51 return ServerInstance(channel,
47 object_store_creator, 52 object_store_creator,
48 host_file_system, 53 host_file_system,
49 app_samples_file_system) 54 app_samples_file_system,
55 create_file_system)
50 56
51 class InstanceServlet(object): 57 class InstanceServlet(object):
52 '''Servlet for running on normal AppEngine instances. 58 '''Servlet for running on normal AppEngine instances.
53 Create this via GetConstructor() so that cache state can be shared amongst 59 Create this via GetConstructor() so that cache state can be shared amongst
54 them via the memoizing Delegate. 60 them via the memoizing Delegate.
55 ''' 61 '''
56 class Delegate(object): 62 class Delegate(object):
57 '''Allow runtime dependencies to be overriden for testing. 63 '''Allow runtime dependencies to be overriden for testing.
58 ''' 64 '''
59 def CreateBranchUtility(self, object_store_creator): 65 def CreateBranchUtility(self, object_store_creator):
60 return BranchUtility.Create(object_store_creator) 66 return BranchUtility.Create(object_store_creator)
61 67
62 def CreateHostFileSystemForBranch(self, branch): 68 def CreateHostFileSystemForBranch(self, branch):
63 return SubversionFileSystem.Create(branch) 69 return SubversionFileSystem.Create(branch)
64 70
65 def CreateAppSamplesFileSystem(self, object_store_creator): 71 def CreateAppSamplesFileSystem(self, object_store_creator):
66 # TODO(kalman): OfflineServerInstance wrapper for GithubFileSystem, but 72 # TODO(kalman): OfflineServerInstance wrapper for GithubFileSystem, but
67 # the cron job doesn't crawl the samples yet. 73 # the cron job doesn't crawl the samples yet.
68 return (EmptyDirFileSystem() if IsDevServer() else 74 return (EmptyDirFileSystem() if IsDevServer() else
69 GithubFileSystem.Create(object_store_creator)) 75 GithubFileSystem.Create(object_store_creator))
70 76
71 @staticmethod 77 @staticmethod
72 def GetConstructor(delegate_for_test=None): 78 def GetConstructor(delegate_for_test=None):
73 render_servlet_delegate = _OfflineRenderServletDelegate( 79 render_servlet_delegate = _OfflineRenderServletDelegate(
74 delegate_for_test or InstanceServlet.Delegate()) 80 delegate_for_test or InstanceServlet.Delegate())
75 return lambda request: RenderServlet(request, render_servlet_delegate) 81 return lambda request: RenderServlet(request, render_servlet_delegate)
76 82
77 # NOTE: if this were a real Servlet it would implement a Get() method, but 83 # NOTE: if this were a real Servlet it would implement a Get() method, but
78 # GetConstructor returns an appropriate lambda function (Request -> Servlet). 84 # GetConstructor returns an appropriate lambda function (Request -> Servlet).
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698