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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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 json 5 import json
6 import logging 6 import logging
7 import operator 7 import operator
8 8
9 from appengine_wrappers import GetAppVersion
9 from object_store_creator import ObjectStoreCreator 10 from object_store_creator import ObjectStoreCreator
10 11
11 class BranchUtility(object): 12 class BranchUtility(object):
12 def __init__(self, fetch_url, fetcher, object_store=None): 13 def __init__(self, fetch_url, fetcher, object_store=None):
13 self._fetch_url = fetch_url 14 self._fetch_url = fetch_url
14 self._fetcher = fetcher 15 self._fetcher = fetcher
15 if object_store is None: 16 if object_store is None:
16 object_store = ObjectStoreCreator(BranchUtility).Create() 17 object_store = (ObjectStoreCreator.SharedFactory(GetAppVersion())
18 .Create(BranchUtility).Create())
17 self._object_store = object_store 19 self._object_store = object_store
18 20
19 @staticmethod 21 @staticmethod
20 def GetAllBranchNames(): 22 def GetAllBranchNames():
21 return ['stable', 'beta', 'dev', 'trunk'] 23 return ['stable', 'beta', 'dev', 'trunk']
22 24
23 def GetAllBranchNumbers(self): 25 def GetAllBranchNumbers(self):
24 return [(branch, self.GetBranchNumberForChannelName(branch)) 26 return [(branch, self.GetBranchNumberForChannelName(branch))
25 for branch in BranchUtility.GetAllBranchNames()] 27 for branch in BranchUtility.GetAllBranchNames()]
26 28
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 else: 72 else:
71 branch_numbers[branch] += 1 73 branch_numbers[branch] += 1
72 74
73 sorted_branches = sorted(branch_numbers.iteritems(), 75 sorted_branches = sorted(branch_numbers.iteritems(),
74 None, 76 None,
75 operator.itemgetter(1), 77 operator.itemgetter(1),
76 True) 78 True)
77 self._object_store.Set(channel_name, sorted_branches[0][0]) 79 self._object_store.Set(channel_name, sorted_branches[0][0])
78 80
79 return sorted_branches[0][0] 81 return sorted_branches[0][0]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698