OLD | NEW |
---|---|
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 import logging | 5 import logging |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 from appengine_wrappers import webapp | 9 from appengine_wrappers import webapp |
10 from appengine_wrappers import memcache | 10 from appengine_wrappers import memcache |
(...skipping 14 matching lines...) Expand all Loading... | |
25 from subversion_file_system import SubversionFileSystem | 25 from subversion_file_system import SubversionFileSystem |
26 from template_data_source import TemplateDataSource | 26 from template_data_source import TemplateDataSource |
27 from appengine_url_fetcher import AppEngineUrlFetcher | 27 from appengine_url_fetcher import AppEngineUrlFetcher |
28 | 28 |
29 # The branch that the server will default to when no branch is specified in the | 29 # The branch that the server will default to when no branch is specified in the |
30 # URL. This is necessary because it is not possible to pass flags to the script | 30 # URL. This is necessary because it is not possible to pass flags to the script |
31 # handler. | 31 # handler. |
32 DEFAULT_BRANCH = 'local' | 32 DEFAULT_BRANCH = 'local' |
33 | 33 |
34 SVN_URL = 'http://src.chromium.org/chrome' | 34 SVN_URL = 'http://src.chromium.org/chrome' |
35 VIEWVC_URL = 'http://src.chromium.org/viewvc/chrome' | |
35 TRUNK_URL = SVN_URL + '/trunk' | 36 TRUNK_URL = SVN_URL + '/trunk' |
36 BRANCH_URL = SVN_URL + '/branches' | 37 BRANCH_URL = SVN_URL + '/branches' |
37 | 38 |
38 OMAHA_PROXY_URL = 'http://omahaproxy.appspot.com/json' | 39 OMAHA_PROXY_URL = 'http://omahaproxy.appspot.com/json' |
39 BRANCH_UTILITY_MEMCACHE = AppEngineMemcache('branch_utility') | 40 BRANCH_UTILITY_MEMCACHE = AppEngineMemcache('branch_utility') |
40 BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL, | 41 BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL, |
41 DEFAULT_BRANCH, | 42 DEFAULT_BRANCH, |
42 AppEngineUrlFetcher(''), | 43 AppEngineUrlFetcher(''), |
43 BRANCH_UTILITY_MEMCACHE) | 44 BRANCH_UTILITY_MEMCACHE) |
44 | 45 |
(...skipping 10 matching lines...) Expand all Loading... | |
55 | 56 |
56 # Global cache of instances because Handler is recreated for every request. | 57 # Global cache of instances because Handler is recreated for every request. |
57 SERVER_INSTANCES = {} | 58 SERVER_INSTANCES = {} |
58 | 59 |
59 def _GetInstanceForBranch(branch, local_path): | 60 def _GetInstanceForBranch(branch, local_path): |
60 if branch in SERVER_INSTANCES: | 61 if branch in SERVER_INSTANCES: |
61 return SERVER_INSTANCES[branch] | 62 return SERVER_INSTANCES[branch] |
62 if branch == 'local': | 63 if branch == 'local': |
63 file_system = LocalFileSystem(local_path) | 64 file_system = LocalFileSystem(local_path) |
64 else: | 65 else: |
65 fetcher = AppEngineUrlFetcher( | 66 svn_url = _GetURLFromBranch(branch) + '/' + EXTENSIONS_PATH |
not at google - send to devlin
2012/08/10 06:42:24
nice
| |
66 _GetURLFromBranch(branch) + '/' + EXTENSIONS_PATH) | 67 stat_fetcher = AppEngineUrlFetcher(svn_url.replace(SVN_URL, VIEWVC_URL)) |
67 file_system = MemcacheFileSystem(SubversionFileSystem(fetcher), | 68 fetcher = AppEngineUrlFetcher(svn_url) |
68 AppEngineMemcache(branch)) | 69 file_system = MemcacheFileSystem( |
70 SubversionFileSystem(fetcher, stat_fetcher), | |
71 AppEngineMemcache(branch)) | |
69 | 72 |
70 cache_builder = FileSystemCache.Builder(file_system) | 73 cache_builder = FileSystemCache.Builder(file_system) |
71 api_list_data_source = APIListDataSource(cache_builder, | 74 api_list_data_source = APIListDataSource(cache_builder, |
72 file_system, | 75 file_system, |
73 API_PATH, | 76 API_PATH, |
74 PUBLIC_TEMPLATE_PATH) | 77 PUBLIC_TEMPLATE_PATH) |
75 intro_data_source = IntroDataSource(cache_builder, | 78 intro_data_source = IntroDataSource(cache_builder, |
76 [INTRO_PATH, ARTICLE_PATH]) | 79 [INTRO_PATH, ARTICLE_PATH]) |
77 samples_data_source_factory = SamplesDataSource.Factory(branch, | 80 samples_data_source_factory = SamplesDataSource.Factory(branch, |
78 file_system, | 81 file_system, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 self._NavigateToPath('stable/extensions/samples.html') | 137 self._NavigateToPath('stable/extensions/samples.html') |
135 return | 138 return |
136 | 139 |
137 # Redirect paths like "directory" to "directory/". This is so relative file | 140 # Redirect paths like "directory" to "directory/". This is so relative file |
138 # paths will know to treat this as a directory. | 141 # paths will know to treat this as a directory. |
139 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 142 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
140 self.redirect(path + '/') | 143 self.redirect(path + '/') |
141 path = path.replace('/chrome/', '') | 144 path = path.replace('/chrome/', '') |
142 path = path.strip('/') | 145 path = path.strip('/') |
143 self._NavigateToPath(path) | 146 self._NavigateToPath(path) |
OLD | NEW |