Chromium Code Reviews| 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 from StringIO import StringIO | 7 from StringIO import StringIO |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from appengine_wrappers import webapp | 10 from appengine_wrappers import webapp |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 self.response) | 159 self.response) |
| 160 | 160 |
| 161 def _Render(self, files, branch): | 161 def _Render(self, files, branch): |
| 162 for f in files: | 162 for f in files: |
| 163 path = branch + f.split(PUBLIC_TEMPLATE_PATH)[-1] | 163 path = branch + f.split(PUBLIC_TEMPLATE_PATH)[-1] |
| 164 self.request = _MockRequest(path) | 164 self.request = _MockRequest(path) |
| 165 self.response = _MockResponse() | 165 self.response = _MockResponse() |
| 166 self._HandleGet(path) | 166 self._HandleGet(path) |
| 167 | 167 |
| 168 def _HandleCron(self, path): | 168 def _HandleCron(self, path): |
| 169 original_response = self.response | |
|
not at google - send to devlin
2012/08/22 13:57:58
rather than this, could you make _Render save then
cduvall
2012/08/22 17:20:43
Done.
| |
| 169 branch = path.split('/')[-1] | 170 branch = path.split('/')[-1] |
| 170 logging.info('Running cron job for %s.' % branch) | 171 logging.info('Running cron job for %s.' % branch) |
| 171 branch_memcache = InMemoryObjectStore(branch) | 172 branch_memcache = InMemoryObjectStore(branch) |
| 172 file_system = _CreateMemcacheFileSystem(branch, branch_memcache) | 173 file_system = _CreateMemcacheFileSystem(branch, branch_memcache) |
| 173 builder = FileSystemCache.Builder(file_system, branch_memcache) | 174 builder = FileSystemCache.Builder(file_system, branch_memcache) |
| 174 render_cache = builder.build(lambda x: self._Render(x, branch), | 175 render_cache = builder.build(lambda x: self._Render(x, branch), |
| 175 fs_cache.RENDER) | 176 fs_cache.RENDER) |
| 176 render_cache.GetFromFileListing(PUBLIC_TEMPLATE_PATH) | 177 render_cache.GetFromFileListing(PUBLIC_TEMPLATE_PATH) |
| 178 original_response.out.write('Success') | |
| 177 | 179 |
| 178 def get(self): | 180 def get(self): |
| 179 path = self.request.path | 181 path = self.request.path |
| 180 if path.startswith('/cron'): | 182 if path.startswith('/cron'): |
| 181 self._HandleCron(path) | 183 self._HandleCron(path) |
| 182 else: | 184 else: |
| 183 # Redirect paths like "directory" to "directory/". This is so relative | 185 # Redirect paths like "directory" to "directory/". This is so relative |
| 184 # file paths will know to treat this as a directory. | 186 # file paths will know to treat this as a directory. |
| 185 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 187 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
| 186 self.redirect(path + '/') | 188 self.redirect(path + '/') |
| 187 path = path.replace('/chrome/', '') | 189 path = path.replace('/chrome/', '') |
| 188 path = path.strip('/') | 190 path = path.strip('/') |
| 189 self._HandleGet(path) | 191 self._HandleGet(path) |
| OLD | NEW |