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

Unified Diff: chrome/common/extensions/docs/server2/handler.py

Issue 10831269: Extensions Docs Server: BranchUtility not fetching branch numbers correctly (fixed) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better testing and 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/handler.py
diff --git a/chrome/common/extensions/docs/server2/handler.py b/chrome/common/extensions/docs/server2/handler.py
index 4f4f9de7e68122109841c36d7d2bf25b61913b0f..3db64ef4ea73dba14691d8f1baf32330c70a02a1 100644
--- a/chrome/common/extensions/docs/server2/handler.py
+++ b/chrome/common/extensions/docs/server2/handler.py
@@ -39,7 +39,7 @@ OMAHA_PROXY_URL = 'http://omahaproxy.appspot.com/json'
BRANCH_UTILITY_MEMCACHE = AppEngineMemcache('branch_utility')
BRANCH_UTILITY = BranchUtility(OMAHA_PROXY_URL,
DEFAULT_BRANCH,
- AppEngineUrlFetcher(''),
+ AppEngineUrlFetcher(None),
BRANCH_UTILITY_MEMCACHE)
STATIC_DIR_PREFIX = 'docs/server2'
@@ -56,7 +56,8 @@ FULL_EXAMPLES_PATH = DOCS_PATH + '/' + EXAMPLES_PATH
# Global cache of instances because Handler is recreated for every request.
SERVER_INSTANCES = {}
-def _GetInstanceForBranch(branch, local_path):
+def _GetInstanceForBranch(channel_name, local_path):
+ branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name)
if branch in SERVER_INSTANCES:
return SERVER_INSTANCES[branch]
if branch == 'local':
@@ -82,7 +83,7 @@ def _GetInstanceForBranch(branch, local_path):
API_PATH,
samples_data_source_factory)
template_data_source_factory = TemplateDataSource.Factory(
- branch,
+ channel_name,
api_data_source_factory,
api_list_data_source,
intro_data_source,
@@ -105,6 +106,12 @@ def _GetURLFromBranch(branch):
return TRUNK_URL + '/src'
return BRANCH_URL + '/' + branch + '/src'
+def _CleanBranches():
+ numbers = BRANCH_UTILITY.GetAllBranchNumbers()
+ for key in SERVER_INSTANCES.keys():
+ if key not in numbers:
+ SERVER_INSTANCES.pop(key)
+
class Handler(webapp.RequestHandler):
def __init__(self, request, response, local_path=EXTENSIONS_PATH):
self._local_path = local_path
@@ -112,23 +119,21 @@ class Handler(webapp.RequestHandler):
def _NavigateToPath(self, path):
channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path)
- branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name)
# TODO: Detect that these are directories and serve index.html out of them.
if real_path.strip('/') == 'apps':
real_path = 'apps/index.html'
if real_path.strip('/') == 'extensions':
real_path = 'extensions/index.html'
- # TODO: This leaks Server instances when branch bumps.
- _GetInstanceForBranch(branch, self._local_path).Get(real_path,
- self.request,
- self.response)
+ _CleanBranches()
+ _GetInstanceForBranch(channel_name, self._local_path).Get(real_path,
+ self.request,
+ self.response)
def get(self):
path = self.request.path
if '_ah/warmup' in path:
logging.info('Warmup request.')
- if DEFAULT_BRANCH != 'local':
- self._NavigateToPath('trunk/extensions/samples.html')
+ self._NavigateToPath('trunk/extensions/samples.html')
self._NavigateToPath('dev/extensions/samples.html')
self._NavigateToPath('beta/extensions/samples.html')
self._NavigateToPath('stable/extensions/samples.html')

Powered by Google App Engine
This is Rietveld 408576698