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

Side by Side Diff: chrome/common/extensions/docs/server2/sidenav_data_source.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 copy 5 import copy
6 import json 6 import json
7 import logging 7 import logging
8 8
9 import compiled_file_system as compiled_fs 9 import compiled_file_system as compiled_fs
10 from third_party.json_schema_compiler.model import UnixName 10 from third_party.json_schema_compiler.model import UnixName
11 11
12 # Increment this if the data model changes for SidenavDataSource.
13 _VERSION = 1
14
15 class SidenavDataSource(object): 12 class SidenavDataSource(object):
16 """This class reads in and caches a JSON file representing the side navigation 13 """This class reads in and caches a JSON file representing the side navigation
17 menu. 14 menu.
18 """ 15 """
19 class Factory(object): 16 class Factory(object):
20 def __init__(self, compiled_fs_factory, json_path): 17 def __init__(self, compiled_fs_factory, json_path):
21 self._cache = compiled_fs_factory.Create(self._CreateSidenavDict, 18 self._cache = compiled_fs_factory.Create(self._CreateSidenavDict,
22 SidenavDataSource, 19 SidenavDataSource)
23 version=_VERSION)
24 self._json_path = json_path 20 self._json_path = json_path
25 21
26 def Create(self, path): 22 def Create(self, path):
27 """Create a SidenavDataSource, binding it to |path|. |path| is the url 23 """Create a SidenavDataSource, binding it to |path|. |path| is the url
28 of the page that is being rendered. It is used to determine which item 24 of the page that is being rendered. It is used to determine which item
29 in the sidenav should be highlighted. 25 in the sidenav should be highlighted.
30 """ 26 """
31 return SidenavDataSource(self._cache, self._json_path, path) 27 return SidenavDataSource(self._cache, self._json_path, path)
32 28
33 def _AddLevels(self, items, level): 29 def _AddLevels(self, items, level):
(...skipping 24 matching lines...) Expand all
58 if self._AddSelected(item['items']): 54 if self._AddSelected(item['items']):
59 item['child_selected'] = True 55 item['child_selected'] = True
60 return True 56 return True
61 return False 57 return False
62 58
63 def get(self, key): 59 def get(self, key):
64 sidenav = copy.deepcopy(self._cache.GetFromFile( 60 sidenav = copy.deepcopy(self._cache.GetFromFile(
65 '%s/%s_sidenav.json' % (self._json_path, key))) 61 '%s/%s_sidenav.json' % (self._json_path, key)))
66 self._AddSelected(sidenav) 62 self._AddSelected(sidenav)
67 return sidenav 63 return sidenav
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698