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

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

Issue 10823105: Extensions Docs Server: Preview server and more integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: previewserver -> preview + fixes 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 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 18 matching lines...) Expand all
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 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 = BranchUtility(OMAHA_PROXY_URL, 40 BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL,
40 DEFAULT_BRANCH, 41 DEFAULT_BRANCH,
41 AppEngineUrlFetcher(''), 42 AppEngineUrlFetcher(''),
42 AppEngineMemcache('branch_utility')) 43 BRANCH_UTILITY_MEMCACHE)
43 44
44 STATIC_DIR_PREFIX = 'docs/server2' 45 STATIC_DIR_PREFIX = 'docs/server2'
45 EXTENSIONS_PATH = 'chrome/common/extensions' 46 EXTENSIONS_PATH = 'chrome/common/extensions'
46 DOCS_PATH = 'docs' 47 DOCS_PATH = 'docs'
47 API_PATH = 'api' 48 API_PATH = 'api'
48 INTRO_PATH = DOCS_PATH + '/server2/templates/intros' 49 INTRO_PATH = DOCS_PATH + '/server2/templates/intros'
49 ARTICLE_PATH = DOCS_PATH + '/server2/templates/articles' 50 ARTICLE_PATH = DOCS_PATH + '/server2/templates/articles'
50 PUBLIC_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/public' 51 PUBLIC_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/public'
51 PRIVATE_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/private' 52 PRIVATE_TEMPLATE_PATH = DOCS_PATH + '/server2/templates/private'
52 EXAMPLES_PATH = DOCS_PATH + '/examples' 53 EXAMPLES_PATH = DOCS_PATH + '/examples'
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 real_path = 'index.html' 115 real_path = 'index.html'
115 # TODO: This leaks Server instances when branch bumps. 116 # TODO: This leaks Server instances when branch bumps.
116 _GetInstanceForBranch(branch, self._local_path).Get(real_path, 117 _GetInstanceForBranch(branch, self._local_path).Get(real_path,
117 self.request, 118 self.request,
118 self.response) 119 self.response)
119 120
120 def get(self): 121 def get(self):
121 path = self.request.path 122 path = self.request.path
122 if '_ah/warmup' in path: 123 if '_ah/warmup' in path:
123 logging.info('Warmup request.') 124 logging.info('Warmup request.')
124 self._NavigateToPath('trunk/samples.html') 125 if DEFAULT_BRANCH != 'local':
126 self._NavigateToPath('trunk/samples.html')
125 self._NavigateToPath('dev/samples.html') 127 self._NavigateToPath('dev/samples.html')
126 self._NavigateToPath('beta/samples.html') 128 self._NavigateToPath('beta/samples.html')
127 self._NavigateToPath('stable/samples.html') 129 self._NavigateToPath('stable/samples.html')
128 return 130 return
129 131
130 # Redirect paths like "directory" to "directory/". This is so relative file 132 # Redirect paths like "directory" to "directory/". This is so relative file
131 # paths will know to treat this as a directory. 133 # paths will know to treat this as a directory.
132 if os.path.splitext(path)[1] == '' and path[-1] != '/': 134 if os.path.splitext(path)[1] == '' and path[-1] != '/':
133 self.redirect(path + '/') 135 self.redirect(path + '/')
134 path = path.replace('/chrome/extensions/', '') 136 path = path.replace('/chrome/extensions/', '')
135 path = path.strip('/') 137 path = path.strip('/')
136 self._NavigateToPath(path) 138 self._NavigateToPath(path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698