Index: chrome/common/extensions/docs/server2/handler.py |
diff --git a/chrome/common/extensions/docs/server2/handler.py b/chrome/common/extensions/docs/server2/handler.py |
index 1adb106ea9aa53766fb8586933ff5dd2a3af36f9..a6f45d07371b862b128b4b83f8889484efaaba06 100644 |
--- a/chrome/common/extensions/docs/server2/handler.py |
+++ b/chrome/common/extensions/docs/server2/handler.py |
@@ -14,13 +14,15 @@ from appengine_wrappers import urlfetch |
from api_data_source import APIDataSource |
from api_list_data_source import APIListDataSource |
from appengine_blobstore import AppEngineBlobstore |
-from in_memory_object_store import InMemoryObjectStore |
from appengine_url_fetcher import AppEngineUrlFetcher |
+from availability_data_source import AvailabilityDataSource |
from branch_utility import BranchUtility |
-from example_zipper import ExampleZipper |
+from chrome_version_data_source import ChromeVersionDataSource |
from compiled_file_system import CompiledFileSystem |
import compiled_file_system as compiled_fs |
+from example_zipper import ExampleZipper |
from github_file_system import GithubFileSystem |
+from in_memory_object_store import InMemoryObjectStore |
from intro_data_source import IntroDataSource |
from known_issues_data_source import KnownIssuesDataSource |
from local_file_system import LocalFileSystem |
@@ -36,7 +38,7 @@ import url_constants |
# Increment this version to force the server to reload all pages in the first |
# cron job that is run. |
-_VERSION = 1 |
+_VERSION = 2 |
# The default channel to serve docs for if no channel is specified. |
_DEFAULT_CHANNEL = 'stable' |
@@ -46,6 +48,10 @@ BRANCH_UTILITY = BranchUtility(url_constants.OMAHA_PROXY_URL, |
AppEngineUrlFetcher(None), |
BRANCH_UTILITY_MEMCACHE) |
+AVAILABILITY_DATA_SOURCE_MEMCACHE = InMemoryObjectStore( |
+ 'availability_data_source') |
+ |
+ |
GITHUB_MEMCACHE = InMemoryObjectStore('github') |
GITHUB_FILE_SYSTEM = GithubFileSystem( |
AppEngineUrlFetcher(url_constants.GITHUB_URL), |
@@ -84,7 +90,40 @@ def _CreateMemcacheFileSystem(branch, branch_memcache): |
return MemcacheFileSystem(SubversionFileSystem(fetcher, stat_fetcher), |
branch_memcache) |
-_default_branch = BRANCH_UTILITY.GetBranchNumberForChannelName(_DEFAULT_CHANNEL) |
+def _CreateMemcacheForBranch(branch_number): |
epeterson
2013/03/25 19:48:02
This is now a global method, which is passed to th
cduvall
2013/03/25 22:59:43
Which objects does it depend on? Can you just pass
|
+ """Passed to the global instance of chromeVersionDataSource. Allows for |
+ the creation of api_data_sources linked to |branch_number|, which is the |
+ maximum branch number from a given version of chrome. |
+ """ |
+ branch_memcache = InMemoryObjectStore(branch_number) |
+ file_system = _CreateMemcacheFileSystem(branch_number, branch_memcache) |
+ cache_factory = CompiledFileSystem.Factory(file_system, branch_memcache) |
+ api_list_data_source_factory = APIListDataSource.Factory( |
+ cache_factory, |
+ file_system, |
+ API_PATH, |
+ PUBLIC_TEMPLATE_PATH) |
+ api_data_source_factory = APIDataSource.Factory(cache_factory, API_PATH) |
+ ref_resolver_factory = ReferenceResolver.Factory( |
+ api_data_source_factory, |
+ api_list_data_source_factory, |
+ branch_memcache) |
+ api_data_source_factory.SetReferenceResolverFactory(ref_resolver_factory) |
+ samples_data_source_factory = SamplesDataSource.Factory( |
+ #channel_name, |
+ 'trunk', |
epeterson
2013/03/25 19:48:02
This is really the only part that prevents this me
cduvall
2013/03/25 22:59:43
Can you just pass the channel name in as a functio
|
+ file_system, |
+ GITHUB_FILE_SYSTEM, |
+ cache_factory, |
+ GITHUB_COMPILED_FILE_SYSTEM, |
+ ref_resolver_factory, |
+ EXAMPLES_PATH) |
+ api_data_source_factory.SetSamplesDataSourceFactory( |
+ samples_data_source_factory) |
+ return api_data_source_factory.Create(None) |
+ |
+_default_branch = BRANCH_UTILITY.GetChannelInfoForChannelName( |
+ _DEFAULT_CHANNEL)['branch'] |
APPS_MEMCACHE = InMemoryObjectStore(_default_branch) |
APPS_FILE_SYSTEM = _CreateMemcacheFileSystem(_default_branch, APPS_MEMCACHE) |
APPS_COMPILED_FILE_SYSTEM = CompiledFileSystem.Factory( |
@@ -102,11 +141,22 @@ KNOWN_ISSUES_DATA_SOURCE = KnownIssuesDataSource( |
InMemoryObjectStore('KnownIssues'), |
AppEngineUrlFetcher(None)) |
+CHROME_VERSION_DATA_SOURCE_MEMCACHE = InMemoryObjectStore( |
+ 'chrome_version_data_source') |
+CHROME_VERSION_DATA_SOURCE = ChromeVersionDataSource( |
+ url_constants.OMAHA_BETA_HISTORY, |
+ AppEngineUrlFetcher(None), |
+ CHROME_VERSION_DATA_SOURCE_MEMCACHE, |
+ _CreateMemcacheForBranch) |
+ |
def _MakeInstanceKey(branch, number): |
return '%s/%s' % (branch, number) |
def _GetInstanceForBranch(channel_name, local_path): |
- branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) |
+ channel_info = BRANCH_UTILITY.GetChannelInfoForChannelName( |
+ channel_name) |
+ branch = channel_info['branch'] |
+ version = channel_info['version'] |
# The key for the server is a tuple of |channel_name| with |branch|, since |
# sometimes stable and beta point to the same branch. |
@@ -114,7 +164,6 @@ def _GetInstanceForBranch(channel_name, local_path): |
instance = SERVER_INSTANCES.get(instance_key, None) |
if instance is not None: |
return instance |
- |
branch_memcache = InMemoryObjectStore(branch) |
file_system = _CreateMemcacheFileSystem(branch, branch_memcache) |
cache_factory = CompiledFileSystem.Factory(file_system, branch_memcache) |
@@ -122,9 +171,14 @@ def _GetInstanceForBranch(channel_name, local_path): |
file_system, |
API_PATH, |
PUBLIC_TEMPLATE_PATH) |
+ availability_data_source = AvailabilityDataSource( |
+ CHROME_VERSION_DATA_SOURCE, |
+ version, |
+ AVAILABILITY_DATA_SOURCE_MEMCACHE) |
api_data_source_factory = APIDataSource.Factory( |
cache_factory, |
- API_PATH) |
+ API_PATH, |
+ availability_data_source) |
# Give the ReferenceResolver a memcache, to speed up the lookup of |
# duplicate $refs. |
@@ -148,7 +202,7 @@ def _GetInstanceForBranch(channel_name, local_path): |
ref_resolver_factory, |
[INTRO_PATH, ARTICLE_PATH]) |
sidenav_data_source_factory = SidenavDataSource.Factory(cache_factory, |
- JSON_PATH) |
+ JSON_PATH) |
cduvall
2013/03/25 22:59:43
revert
epeterson
2013/03/27 22:36:09
Done, in the new global method.
|
template_data_source_factory = TemplateDataSource.Factory( |
channel_name, |
api_data_source_factory, |
@@ -160,11 +214,11 @@ def _GetInstanceForBranch(channel_name, local_path): |
cache_factory, |
ref_resolver_factory, |
PUBLIC_TEMPLATE_PATH, |
- PRIVATE_TEMPLATE_PATH) |
+ PRIVATE_TEMPLATE_PATH, |
+ BRANCH_UTILITY.GetChannelInfoForAllChannels()) |
example_zipper = ExampleZipper(file_system, |
cache_factory, |
DOCS_PATH) |
- |
instance = ServerInstance(template_data_source_factory, |
example_zipper, |
cache_factory) |
@@ -226,7 +280,6 @@ class Handler(webapp.RequestHandler): |
_GetInstanceForBranch(channel_name, self._local_path).Get(real_path, |
self.request, |
self.response) |
- |
def _Render(self, files, channel): |
original_response = self.response |
for f in files: |
@@ -266,7 +319,7 @@ class Handler(webapp.RequestHandler): |
# be called. The same is then done separately with the apps samples page, |
# since it pulls its data from Github. |
channel = path.split('/')[-1] |
- branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel) |
+ branch = BRANCH_UTILITY.GetChannelInfoForChannelName(channel)['branch'] |
logging.info('Running cron job for %s.' % branch) |
branch_memcache = InMemoryObjectStore(branch) |
file_system = _CreateMemcacheFileSystem(branch, branch_memcache) |