Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: chrome/common/extensions/docs/server2/handler.py

Issue 10871002: Extensions Docs Server: Testing GithubFileSystem and cron jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small changes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if real_path.strip('/') == 'apps': 152 if real_path.strip('/') == 'apps':
153 real_path = 'apps/index.html' 153 real_path = 'apps/index.html'
154 if real_path.strip('/') == 'extensions': 154 if real_path.strip('/') == 'extensions':
155 real_path = 'extensions/index.html' 155 real_path = 'extensions/index.html'
156 _CleanBranches() 156 _CleanBranches()
157 _GetInstanceForBranch(channel_name, self._local_path).Get(real_path, 157 _GetInstanceForBranch(channel_name, self._local_path).Get(real_path,
158 self.request, 158 self.request,
159 self.response) 159 self.response)
160 160
161 def _Render(self, files, branch): 161 def _Render(self, files, branch):
162 original_response = self.response
162 for f in files: 163 for f in files:
163 path = branch + f.split(PUBLIC_TEMPLATE_PATH)[-1] 164 path = branch + f.split(PUBLIC_TEMPLATE_PATH)[-1]
164 self.request = _MockRequest(path) 165 self.request = _MockRequest(path)
165 self.response = _MockResponse() 166 self.response = _MockResponse()
166 self._HandleGet(path) 167 self._HandleGet(path)
168 self.response = original_response
167 169
168 def _HandleCron(self, path): 170 def _HandleCron(self, path):
169 branch = path.split('/')[-1] 171 branch = path.split('/')[-1]
170 logging.info('Running cron job for %s.' % branch) 172 logging.info('Running cron job for %s.' % branch)
171 branch_memcache = InMemoryObjectStore(branch) 173 branch_memcache = InMemoryObjectStore(branch)
172 file_system = _CreateMemcacheFileSystem(branch, branch_memcache) 174 file_system = _CreateMemcacheFileSystem(branch, branch_memcache)
173 builder = FileSystemCache.Builder(file_system, branch_memcache) 175 builder = FileSystemCache.Builder(file_system, branch_memcache)
174 render_cache = builder.build(lambda x: self._Render(x, branch), 176 render_cache = builder.build(lambda x: self._Render(x, branch),
175 fs_cache.RENDER) 177 fs_cache.RENDER)
176 render_cache.GetFromFileListing(PUBLIC_TEMPLATE_PATH) 178 render_cache.GetFromFileListing(PUBLIC_TEMPLATE_PATH)
179 self.response.out.write('Success')
177 180
178 def get(self): 181 def get(self):
179 path = self.request.path 182 path = self.request.path
180 if path.startswith('/cron'): 183 if path.startswith('/cron'):
181 self._HandleCron(path) 184 self._HandleCron(path)
182 else: 185 else:
183 # Redirect paths like "directory" to "directory/". This is so relative 186 # Redirect paths like "directory" to "directory/". This is so relative
184 # file paths will know to treat this as a directory. 187 # file paths will know to treat this as a directory.
185 if os.path.splitext(path)[1] == '' and path[-1] != '/': 188 if os.path.splitext(path)[1] == '' and path[-1] != '/':
186 self.redirect(path + '/') 189 self.redirect(path + '/')
187 path = path.replace('/chrome/', '') 190 path = path.replace('/chrome/', '')
188 path = path.strip('/') 191 path = path.strip('/')
189 self._HandleGet(path) 192 self._HandleGet(path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698