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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 return BRANCH_URL + '/' + branch + '/src' | 106 return BRANCH_URL + '/' + branch + '/src' |
107 | 107 |
108 class Handler(webapp.RequestHandler): | 108 class Handler(webapp.RequestHandler): |
109 def __init__(self, request, response, local_path=EXTENSIONS_PATH): | 109 def __init__(self, request, response, local_path=EXTENSIONS_PATH): |
110 self._local_path = local_path | 110 self._local_path = local_path |
111 super(Handler, self).__init__(request, response) | 111 super(Handler, self).__init__(request, response) |
112 | 112 |
113 def _NavigateToPath(self, path): | 113 def _NavigateToPath(self, path): |
114 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path) | 114 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path) |
115 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) | 115 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) |
116 if real_path == '': | 116 if real_path.strip('/') == 'apps': |
117 real_path = 'index.html' | 117 real_path = 'apps/index.html' |
118 if real_path.strip('/') == 'extensions': | |
119 real_path = 'extensions/index.html' | |
not at google - send to devlin
2012/08/06 22:01:24
would be nice to do a webserver-y kind of thing an
cduvall
2012/08/06 22:25:45
Done.
| |
118 # TODO: This leaks Server instances when branch bumps. | 120 # TODO: This leaks Server instances when branch bumps. |
119 _GetInstanceForBranch(branch, self._local_path).Get(real_path, | 121 _GetInstanceForBranch(branch, self._local_path).Get(real_path, |
120 self.request, | 122 self.request, |
121 self.response) | 123 self.response) |
122 | 124 |
123 def get(self): | 125 def get(self): |
124 path = self.request.path | 126 path = self.request.path |
125 if '_ah/warmup' in path: | 127 if '_ah/warmup' in path: |
126 logging.info('Warmup request.') | 128 logging.info('Warmup request.') |
127 if DEFAULT_BRANCH != 'local': | 129 if DEFAULT_BRANCH != 'local': |
128 self._NavigateToPath('trunk/samples.html') | 130 self._NavigateToPath('extensions/trunk/samples.html') |
129 self._NavigateToPath('dev/samples.html') | 131 self._NavigateToPath('extensions/dev/samples.html') |
130 self._NavigateToPath('beta/samples.html') | 132 self._NavigateToPath('extensions/beta/samples.html') |
131 self._NavigateToPath('stable/samples.html') | 133 self._NavigateToPath('extensions/stable/samples.html') |
132 return | 134 return |
133 | 135 |
134 # Redirect paths like "directory" to "directory/". This is so relative file | 136 # Redirect paths like "directory" to "directory/". This is so relative file |
135 # paths will know to treat this as a directory. | 137 # paths will know to treat this as a directory. |
136 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 138 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
137 self.redirect(path + '/') | 139 self.redirect(path + '/') |
138 path = path.replace('/chrome/extensions/', '') | 140 path = path.replace('/chrome/', '') |
139 path = path.strip('/') | 141 path = path.strip('/') |
140 self._NavigateToPath(path) | 142 self._NavigateToPath(path) |
OLD | NEW |