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 21 matching lines...) Expand all Loading... | |
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 TRUNK_URL = SVN_URL + '/trunk' | 35 TRUNK_URL = SVN_URL + '/trunk' |
36 BRANCH_URL = SVN_URL + '/branches' | 36 BRANCH_URL = SVN_URL + '/branches' |
37 | 37 |
38 OMAHA_PROXY_URL = 'http://omahaproxy.appspot.com/json' | 38 OMAHA_PROXY_URL = 'http://omahaproxy.appspot.com/json' |
39 BRANCH_UTILITY_MEMCACHE = AppEngineMemcache('branch_utility') | 39 BRANCH_UTILITY_MEMCACHE = AppEngineMemcache('branch_utility') |
40 BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL, | 40 BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL, |
41 DEFAULT_BRANCH, | 41 DEFAULT_BRANCH, |
42 AppEngineUrlFetcher(''), | 42 AppEngineUrlFetcher(None), |
43 BRANCH_UTILITY_MEMCACHE) | 43 BRANCH_UTILITY_MEMCACHE) |
44 | 44 |
45 STATIC_DIR_PREFIX = 'docs/server2' | 45 STATIC_DIR_PREFIX = 'docs/server2' |
46 EXTENSIONS_PATH = 'chrome/common/extensions' | 46 EXTENSIONS_PATH = 'chrome/common/extensions' |
47 DOCS_PATH = 'docs' | 47 DOCS_PATH = 'docs' |
48 API_PATH = 'api' | 48 API_PATH = 'api' |
49 INTRO_PATH = DOCS_PATH + '/server2/templates/intros' | 49 INTRO_PATH = DOCS_PATH + '/server2/templates/intros' |
50 ARTICLE_PATH = DOCS_PATH + '/server2/templates/articles' | 50 ARTICLE_PATH = DOCS_PATH + '/server2/templates/articles' |
51 PUBLIC_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/public' | 51 PUBLIC_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/public' |
52 PRIVATE_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/private' | 52 PRIVATE_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/private' |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 template_data_source_factory, | 98 template_data_source_factory, |
99 example_zipper, | 99 example_zipper, |
100 cache_builder) | 100 cache_builder) |
101 return SERVER_INSTANCES[branch] | 101 return SERVER_INSTANCES[branch] |
102 | 102 |
103 def _GetURLFromBranch(branch): | 103 def _GetURLFromBranch(branch): |
104 if branch == 'trunk': | 104 if branch == 'trunk': |
105 return TRUNK_URL + '/src' | 105 return TRUNK_URL + '/src' |
106 return BRANCH_URL + '/' + branch + '/src' | 106 return BRANCH_URL + '/' + branch + '/src' |
107 | 107 |
108 def _CleanBranches(): | |
109 numbers = [BRANCH_UTILITY.GetBranchNumberForChannelName(branch) | |
110 for branch in ['dev', 'beta', 'stable', 'trunk', 'local']] | |
not at google - send to devlin
2012/08/13 00:53:00
currently only the branch utility knows what the a
cduvall
2012/08/13 21:45:04
Done.
| |
111 for key in SERVER_INSTANCES.keys(): | |
112 if key not in numbers: | |
113 SERVER_INSTANCES.pop(key) | |
114 | |
108 class Handler(webapp.RequestHandler): | 115 class Handler(webapp.RequestHandler): |
109 def __init__(self, request, response, local_path=EXTENSIONS_PATH): | 116 def __init__(self, request, response, local_path=EXTENSIONS_PATH): |
110 self._local_path = local_path | 117 self._local_path = local_path |
111 super(Handler, self).__init__(request, response) | 118 super(Handler, self).__init__(request, response) |
112 | 119 |
113 def _NavigateToPath(self, path): | 120 def _NavigateToPath(self, path): |
114 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path) | 121 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path) |
115 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) | 122 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) |
116 # TODO: Detect that these are directories and serve index.html out of them. | 123 # TODO: Detect that these are directories and serve index.html out of them. |
117 if real_path.strip('/') == 'apps': | 124 if real_path.strip('/') == 'apps': |
118 real_path = 'apps/index.html' | 125 real_path = 'apps/index.html' |
119 if real_path.strip('/') == 'extensions': | 126 if real_path.strip('/') == 'extensions': |
120 real_path = 'extensions/index.html' | 127 real_path = 'extensions/index.html' |
121 # TODO: This leaks Server instances when branch bumps. | 128 _CleanBranches() |
122 _GetInstanceForBranch(branch, self._local_path).Get(real_path, | 129 _GetInstanceForBranch(branch, self._local_path).Get(real_path, |
130 channel_name, | |
not at google - send to devlin
2012/08/13 00:53:00
why can't this go in the constructor of template_d
cduvall
2012/08/13 21:45:04
Done.
| |
123 self.request, | 131 self.request, |
124 self.response) | 132 self.response) |
125 | 133 |
126 def get(self): | 134 def get(self): |
127 path = self.request.path | 135 path = self.request.path |
128 if '_ah/warmup' in path: | 136 if '_ah/warmup' in path: |
129 logging.info('Warmup request.') | 137 logging.info('Warmup request.') |
130 if DEFAULT_BRANCH != 'local': | 138 if DEFAULT_BRANCH != 'local': |
131 self._NavigateToPath('trunk/extensions/samples.html') | 139 self._NavigateToPath('trunk/extensions/samples.html') |
132 self._NavigateToPath('dev/extensions/samples.html') | 140 self._NavigateToPath('dev/extensions/samples.html') |
133 self._NavigateToPath('beta/extensions/samples.html') | 141 self._NavigateToPath('beta/extensions/samples.html') |
134 self._NavigateToPath('stable/extensions/samples.html') | 142 self._NavigateToPath('stable/extensions/samples.html') |
135 return | 143 return |
136 | 144 |
137 # Redirect paths like "directory" to "directory/". This is so relative file | 145 # Redirect paths like "directory" to "directory/". This is so relative file |
138 # paths will know to treat this as a directory. | 146 # paths will know to treat this as a directory. |
139 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 147 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
140 self.redirect(path + '/') | 148 self.redirect(path + '/') |
141 path = path.replace('/chrome/', '') | 149 path = path.replace('/chrome/', '') |
142 path = path.strip('/') | 150 path = path.strip('/') |
143 self._NavigateToPath(path) | 151 self._NavigateToPath(path) |
OLD | NEW |