summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/PRESUBMIT.py18
-rw-r--r--chrome/common/extensions/docs/server2/api_data_source.py7
-rwxr-xr-xchrome/common/extensions/docs/server2/api_data_source_test.py2
-rw-r--r--chrome/common/extensions/docs/server2/api_list_data_source.py26
-rwxr-xr-xchrome/common/extensions/docs/server2/api_list_data_source_test.py2
-rw-r--r--chrome/common/extensions/docs/server2/appengine_wrappers.py13
-rw-r--r--chrome/common/extensions/docs/server2/branch_utility.py4
-rw-r--r--chrome/common/extensions/docs/server2/caching_file_system.py3
-rwxr-xr-xchrome/common/extensions/docs/server2/caching_file_system_test.py6
-rw-r--r--chrome/common/extensions/docs/server2/compiled_file_system.py17
-rwxr-xr-xchrome/common/extensions/docs/server2/compiled_file_system_test.py27
-rw-r--r--chrome/common/extensions/docs/server2/example_zipper.py6
-rwxr-xr-xchrome/common/extensions/docs/server2/example_zipper_test.py2
-rw-r--r--chrome/common/extensions/docs/server2/file_system.py7
-rw-r--r--chrome/common/extensions/docs/server2/github_file_system.py5
-rw-r--r--chrome/common/extensions/docs/server2/intro_data_source.py6
-rw-r--r--chrome/common/extensions/docs/server2/object_store_creator.py46
-rwxr-xr-xchrome/common/extensions/docs/server2/object_store_creator_test.py28
-rw-r--r--chrome/common/extensions/docs/server2/offline_file_system.py9
-rwxr-xr-xchrome/common/extensions/docs/server2/path_canonicalizer_test.py2
-rw-r--r--chrome/common/extensions/docs/server2/samples_data_source.py6
-rw-r--r--chrome/common/extensions/docs/server2/server_instance.py9
-rw-r--r--chrome/common/extensions/docs/server2/sidenav_data_source.py6
-rwxr-xr-xchrome/common/extensions/docs/server2/sidenav_data_source_test.py2
-rw-r--r--chrome/common/extensions/docs/server2/subversion_file_system.py12
-rw-r--r--chrome/common/extensions/docs/server2/template_data_source.py6
-rwxr-xr-xchrome/common/extensions/docs/server2/template_data_source_test.py13
27 files changed, 114 insertions, 176 deletions
diff --git a/chrome/common/extensions/PRESUBMIT.py b/chrome/common/extensions/PRESUBMIT.py
index d5c1989..466f17d 100644
--- a/chrome/common/extensions/PRESUBMIT.py
+++ b/chrome/common/extensions/PRESUBMIT.py
@@ -92,24 +92,6 @@ def _CheckHeadingIDs(input_api):
bad_files.append(name)
return bad_files
-def _CheckVersions(input_api, output_api, results):
- version = '_VERSION ='
- for affected_file in input_api.AffectedFiles():
- local_path = affected_file.LocalPath()
- if not fnmatch.fnmatch(local_path, '%s*' % SERVER2_PATH):
- continue
- if local_path.endswith('PRESUBMIT.py'):
- continue
- if any(version in line for line in affected_file.NewContents()):
- found = False
- for _, text in affected_file.ChangedContents():
- if version in text:
- found = True
- break
- if not found:
- results.append(output_api.PresubmitPromptWarning(
- '_VERSION of %s needs to be incremented.' % affected_file))
-
def _CheckLinks(input_api, output_api, results):
for affected_file in input_api.AffectedFiles():
name = affected_file.LocalPath()
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 9afa3dd..8194833 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -11,10 +11,6 @@ import third_party.json_schema_compiler.model as model
import third_party.json_schema_compiler.idl_schema as idl_schema
import third_party.json_schema_compiler.idl_parser as idl_parser
-# Increment this if the data model changes for APIDataSource.
-# This would include changes to model.py in json_schema_compiler!
-_VERSION = 17
-
def _RemoveNoDocs(item):
if json_parse.IsDict(item):
if item.get('nodoc', False):
@@ -266,8 +262,7 @@ class APIDataSource(object):
class Factory(object):
def __init__(self, compiled_fs_factory, base_path):
def create_compiled_fs(fn, category):
- return compiled_fs_factory.Create(
- fn, APIDataSource, category=category, version=_VERSION)
+ return compiled_fs_factory.Create(fn, APIDataSource, category=category)
self._permissions_cache = create_compiled_fs(self._LoadPermissions,
'permissions')
diff --git a/chrome/common/extensions/docs/server2/api_data_source_test.py b/chrome/common/extensions/docs/server2/api_data_source_test.py
index db1a7f5..5e93588 100755
--- a/chrome/common/extensions/docs/server2/api_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/api_data_source_test.py
@@ -59,7 +59,7 @@ class APIDataSourceTest(unittest.TestCase):
self._LoadJSON(filename))
return ReferenceResolver.Factory(data_source,
data_source,
- ObjectStoreCreator.Factory()).Create()
+ ObjectStoreCreator.TestFactory()).Create()
def _LoadJSON(self, filename):
return json.loads(self._ReadLocalFile(filename))
diff --git a/chrome/common/extensions/docs/server2/api_list_data_source.py b/chrome/common/extensions/docs/server2/api_list_data_source.py
index 939b4b6..6501808 100644
--- a/chrome/common/extensions/docs/server2/api_list_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_list_data_source.py
@@ -8,14 +8,6 @@ import os
import third_party.json_schema_compiler.model as model
import docs_server_utils as utils
-# Increment this if the data model changes for APIDataSource.
-_VERSION = 1
-
-# These files are special cases that shouldn't be in the API list.
-IGNORED_FILES = [
- 'devtools'
-]
-
class APIListDataSource(object):
""" This class creates a list of chrome.* APIs and chrome.experimental.* APIs
for extensions and apps that are used in the api_index.html and
@@ -28,8 +20,8 @@ class APIListDataSource(object):
"""
class Factory(object):
def __init__(self, compiled_fs_factory, api_path, public_path):
- self._compiled_fs = compiled_fs_factory.Create(
- self._ListAPIs, APIListDataSource, version=_VERSION)
+ self._compiled_fs = compiled_fs_factory.Create(self._ListAPIs,
+ APIListDataSource)
self._identity_fs = compiled_fs_factory.GetOrCreateIdentity()
def Normalize(string):
return string if string.endswith('/') else (string + '/')
@@ -44,15 +36,13 @@ class APIListDataSource(object):
experimental_apis = []
chrome_apis = []
for template_name in sorted(template_names):
- if template_name in IGNORED_FILES:
+ if model.UnixName(template_name) not in api_names:
continue
- if model.UnixName(template_name) in api_names:
- if template_name.startswith('experimental'):
- experimental_apis.append({
- 'name': template_name.replace('_', '.')
- })
- else:
- chrome_apis.append({ 'name': template_name.replace('_', '.') })
+ entry = {'name': template_name.replace('_', '.')}
+ if template_name.startswith('experimental'):
+ experimental_apis.append(entry)
+ else:
+ chrome_apis.append(entry)
if len(chrome_apis):
chrome_apis[-1]['last'] = True
if len(experimental_apis):
diff --git a/chrome/common/extensions/docs/server2/api_list_data_source_test.py b/chrome/common/extensions/docs/server2/api_list_data_source_test.py
index 1814cc1..4a90d15 100755
--- a/chrome/common/extensions/docs/server2/api_list_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/api_list_data_source_test.py
@@ -53,7 +53,7 @@ class APIListDataSourceTest(unittest.TestCase):
def setUp(self):
self._factory = APIListDataSource.Factory(
CompiledFileSystem.Factory(TestFileSystem(deepcopy(_TEST_DATA)),
- ObjectStoreCreator.Factory()),
+ ObjectStoreCreator.TestFactory()),
'api',
'public')
diff --git a/chrome/common/extensions/docs/server2/appengine_wrappers.py b/chrome/common/extensions/docs/server2/appengine_wrappers.py
index b635742..cf0562d 100644
--- a/chrome/common/extensions/docs/server2/appengine_wrappers.py
+++ b/chrome/common/extensions/docs/server2/appengine_wrappers.py
@@ -4,6 +4,19 @@
import os
+def GetAppVersion():
+ if 'CURRENT_VERSION_ID' in os.environ:
+ return os.environ['CURRENT_VERSION_ID']
+ # Not running on appengine, get it from the app.yaml file ourselves. We
+ # could properly parse this using a yaml library but Python doesn't have
+ # one built in so whatevs.
+ version_key = 'version:'
+ app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml')
+ with open(app_yaml_path, 'r') as app_yaml:
+ version_line = [line for line in app_yaml.read().split('\n')
+ if line.startswith(version_key)][0]
+ return version_line[len(version_key):].strip()
+
def IsDevServer():
return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0
diff --git a/chrome/common/extensions/docs/server2/branch_utility.py b/chrome/common/extensions/docs/server2/branch_utility.py
index 282c6a4..633c5f3 100644
--- a/chrome/common/extensions/docs/server2/branch_utility.py
+++ b/chrome/common/extensions/docs/server2/branch_utility.py
@@ -6,6 +6,7 @@ import json
import logging
import operator
+from appengine_wrappers import GetAppVersion
from object_store_creator import ObjectStoreCreator
class BranchUtility(object):
@@ -13,7 +14,8 @@ class BranchUtility(object):
self._fetch_url = fetch_url
self._fetcher = fetcher
if object_store is None:
- object_store = ObjectStoreCreator(BranchUtility).Create()
+ object_store = (ObjectStoreCreator.SharedFactory(GetAppVersion())
+ .Create(BranchUtility).Create())
self._object_store = object_store
@staticmethod
diff --git a/chrome/common/extensions/docs/server2/caching_file_system.py b/chrome/common/extensions/docs/server2/caching_file_system.py
index ea02a44..8ddfeeb 100644
--- a/chrome/common/extensions/docs/server2/caching_file_system.py
+++ b/chrome/common/extensions/docs/server2/caching_file_system.py
@@ -33,8 +33,7 @@ class CachingFileSystem(FileSystem):
self._file_system = file_system
def create_object_store(category):
return (object_store_creator_factory.Create(CachingFileSystem)
- .Create(category='%s/%s' % (file_system.GetName(), category),
- version=file_system.GetVersion()))
+ .Create(category='%s/%s' % (file_system.GetName(), category)))
self._stat_object_store = create_object_store('stat')
self._read_object_store = create_object_store('read')
self._read_binary_object_store = create_object_store('read-binary')
diff --git a/chrome/common/extensions/docs/server2/caching_file_system_test.py b/chrome/common/extensions/docs/server2/caching_file_system_test.py
index 393328d..d806520 100755
--- a/chrome/common/extensions/docs/server2/caching_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/caching_file_system_test.py
@@ -21,7 +21,7 @@ def _CreateLocalFs():
class CachingFileSystemTest(unittest.TestCase):
def testReadFiles(self):
file_system = CachingFileSystem(_CreateLocalFs(),
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
expected = {
'./test1.txt': 'test1\n',
'./test2.txt': 'test2\n',
@@ -33,7 +33,7 @@ class CachingFileSystemTest(unittest.TestCase):
def testListDir(self):
file_system = CachingFileSystem(_CreateLocalFs(),
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
expected = ['dir/'] + ['file%d.html' % i for i in range(7)]
file_system._read_object_store.Set(
'list/',
@@ -55,7 +55,7 @@ class CachingFileSystemTest(unittest.TestCase):
'bob3': 'bob/bob3 contents',
}
})
- file_system = CachingFileSystem(fake_fs, ObjectStoreCreator.Factory())
+ file_system = CachingFileSystem(fake_fs, ObjectStoreCreator.TestFactory())
self.assertEqual('bob/bob0 contents', file_system.ReadSingle('bob/bob0'))
self.assertTrue(fake_fs.CheckAndReset(read_count=1, stat_count=1))
diff --git a/chrome/common/extensions/docs/server2/compiled_file_system.py b/chrome/common/extensions/docs/server2/compiled_file_system.py
index 1ee0887c..283ac6d 100644
--- a/chrome/common/extensions/docs/server2/compiled_file_system.py
+++ b/chrome/common/extensions/docs/server2/compiled_file_system.py
@@ -23,12 +23,12 @@ class CompiledFileSystem(object):
self._store_type = store_type
self._identity_instance = None
- def Create(self, populate_function, cls, category=None, version=None):
+ def Create(self, populate_function, cls, category=None):
"""Create a CompiledFileSystem that populates the cache by calling
|populate_function| with (path, data), where |data| is the data that was
fetched from |path|.
The namespace for the file system is derived like ObjectStoreCreator: from
- |cls| along with an optional |category| and |version|.
+ |cls| along with an optional |category|.
"""
assert isinstance(cls, type)
assert not cls.__name__[0].islower() # guard against non-class types
@@ -36,10 +36,7 @@ class CompiledFileSystem(object):
if category is not None:
full_name = '%s/%s' % (full_name, category)
# TODO(kalman): Fix ServerInstance.CreateForTest to not give an empty FS.
- if self._file_system and self._file_system.GetVersion() is not None:
- version = (self._file_system.GetVersion() +
- (version if version is not None else 0))
- return self._Create(populate_function, full_name, version=version)
+ return self._Create(populate_function, full_name)
def GetOrCreateIdentity(self):
'''Handy helper to get or create the identity compiled file system.
@@ -50,17 +47,15 @@ class CompiledFileSystem(object):
self._identity_instance = self._Create(lambda _, x: x, 'id')
return self._identity_instance
- def _Create(self, populate_function, full_name, version=None):
+ def _Create(self, populate_function, full_name):
object_store_creator = self._object_store_creator_factory.Create(
CompiledFileSystem,
store_type=self._store_type)
return CompiledFileSystem(
self._file_system,
populate_function,
- object_store_creator.Create(category='%s/file' % full_name,
- version=version),
- object_store_creator.Create(category='%s/list' % full_name,
- version=version))
+ object_store_creator.Create(category='%s/file' % full_name),
+ object_store_creator.Create(category='%s/list' % full_name))
def __init__(self,
file_system,
diff --git a/chrome/common/extensions/docs/server2/compiled_file_system_test.py b/chrome/common/extensions/docs/server2/compiled_file_system_test.py
index 5f5bd1d..419034e 100755
--- a/chrome/common/extensions/docs/server2/compiled_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/compiled_file_system_test.py
@@ -28,17 +28,17 @@ _TEST_DATA = {
def _CreateFactory():
return CompiledFileSystem.Factory(TestFileSystem(deepcopy(_TEST_DATA)),
- ObjectStoreCreator.Factory(),
+ ObjectStoreCreator.Factory('3-0', 'test'),
store_type=TestObjectStore)
class CompiledFileSystemTest(unittest.TestCase):
def testIdentityNamespace(self):
factory = _CreateFactory()
compiled_fs = factory.GetOrCreateIdentity()
- self.assertEqual('CompiledFileSystem/id/file',
+ self.assertEqual('3-0/CompiledFileSystem@test/id/file',
compiled_fs._file_object_store.namespace)
compiled_fs = factory.GetOrCreateIdentity() # should be the same
- self.assertEqual('CompiledFileSystem/id/list',
+ self.assertEqual('3-0/CompiledFileSystem@test/id/list',
compiled_fs._list_object_store.namespace)
def testIdentityFromFile(self):
@@ -69,19 +69,14 @@ class CompiledFileSystemTest(unittest.TestCase):
self.assertEqual(expected_list, fs._list_object_store.namespace)
factory = _CreateFactory()
f = lambda x: x
- CheckNamespace('CompiledFileSystem/CompiledFileSystemTest/file',
- 'CompiledFileSystem/CompiledFileSystemTest/list',
- factory.Create(f, CompiledFileSystemTest))
- CheckNamespace('CompiledFileSystem/CompiledFileSystemTest/foo/file',
- 'CompiledFileSystem/CompiledFileSystemTest/foo/list',
- factory.Create(f, CompiledFileSystemTest, category='foo'))
- CheckNamespace('CompiledFileSystem/CompiledFileSystemTest/file/6',
- 'CompiledFileSystem/CompiledFileSystemTest/list/6',
- factory.Create(f, CompiledFileSystemTest, version=6))
- CheckNamespace('CompiledFileSystem/CompiledFileSystemTest/foo/file/6',
- 'CompiledFileSystem/CompiledFileSystemTest/foo/list/6',
- factory.Create(f, CompiledFileSystemTest, category='foo',
- version=6))
+ CheckNamespace(
+ '3-0/CompiledFileSystem@test/CompiledFileSystemTest/file',
+ '3-0/CompiledFileSystem@test/CompiledFileSystemTest/list',
+ factory.Create(f, CompiledFileSystemTest))
+ CheckNamespace(
+ '3-0/CompiledFileSystem@test/CompiledFileSystemTest/foo/file',
+ '3-0/CompiledFileSystem@test/CompiledFileSystemTest/foo/list',
+ factory.Create(f, CompiledFileSystemTest, category='foo'))
def testPopulateFromFile(self):
def Sleepy(key, val):
diff --git a/chrome/common/extensions/docs/server2/example_zipper.py b/chrome/common/extensions/docs/server2/example_zipper.py
index eb67215..8715001 100644
--- a/chrome/common/extensions/docs/server2/example_zipper.py
+++ b/chrome/common/extensions/docs/server2/example_zipper.py
@@ -9,9 +9,6 @@ from zipfile import ZipFile
import compiled_file_system as compiled_fs
-# Increment this if the data model changes for ExampleZipper.
-_VERSION = 1
-
class ExampleZipper(object):
"""This class creates a zip file given a samples directory.
"""
@@ -21,8 +18,7 @@ class ExampleZipper(object):
# data source. Otherwise we'd need to fetch the zip files from the cron job.
self._file_cache = compiled_fs_factory.GetOrCreateIdentity()
self._zip_cache = compiled_fs_factory.Create(self._MakeZipFile,
- ExampleZipper,
- version=_VERSION)
+ ExampleZipper)
def _MakeZipFile(self, base_dir, files):
if 'manifest.json' not in files:
diff --git a/chrome/common/extensions/docs/server2/example_zipper_test.py b/chrome/common/extensions/docs/server2/example_zipper_test.py
index e396c8d..299c244 100755
--- a/chrome/common/extensions/docs/server2/example_zipper_test.py
+++ b/chrome/common/extensions/docs/server2/example_zipper_test.py
@@ -15,7 +15,7 @@ from object_store_creator import ObjectStoreCreator
class ExampleZipperTest(unittest.TestCase):
def setUp(self):
- object_store_creator_factory = ObjectStoreCreator.Factory()
+ object_store_creator_factory = ObjectStoreCreator.TestFactory()
self._file_system = CachingFileSystem(
LocalFileSystem(os.path.join(sys.path[0], 'test_data')),
object_store_creator_factory)
diff --git a/chrome/common/extensions/docs/server2/file_system.py b/chrome/common/extensions/docs/server2/file_system.py
index da0bbcb..c84ce96 100644
--- a/chrome/common/extensions/docs/server2/file_system.py
+++ b/chrome/common/extensions/docs/server2/file_system.py
@@ -69,10 +69,3 @@ class FileSystem(object):
their caches. It is unlikely that this needs to be overridden.
'''
return cls.__name__
-
- @classmethod
- def GetVersion(cls):
- '''The version of the file system, exposed for caching classes backed to
- file systems. It is unlikely that this needs to be overridden.
- '''
- return None
diff --git a/chrome/common/extensions/docs/server2/github_file_system.py b/chrome/common/extensions/docs/server2/github_file_system.py
index adbef9e..65819a9 100644
--- a/chrome/common/extensions/docs/server2/github_file_system.py
+++ b/chrome/common/extensions/docs/server2/github_file_system.py
@@ -7,7 +7,7 @@ import logging
import os
import appengine_blobstore as blobstore
-from appengine_wrappers import urlfetch
+from appengine_wrappers import GetAppVersion, urlfetch
from file_system import FileSystem, StatInfo
from future import Future
from object_store_creator import ObjectStoreCreator
@@ -63,7 +63,8 @@ class GithubFileSystem(FileSystem):
"""
def __init__(self, fetcher, blobstore):
self._fetcher = fetcher
- self._stat_object_store = ObjectStoreCreator(GithubFileSystem).Create()
+ self._stat_object_store = (ObjectStoreCreator.SharedFactory(GetAppVersion())
+ .Create(GithubFileSystem).Create())
self._blobstore = blobstore
self._version = None
self._GetZip(self.Stat(ZIP_KEY).version)
diff --git a/chrome/common/extensions/docs/server2/intro_data_source.py b/chrome/common/extensions/docs/server2/intro_data_source.py
index b4407c0..53034de 100644
--- a/chrome/common/extensions/docs/server2/intro_data_source.py
+++ b/chrome/common/extensions/docs/server2/intro_data_source.py
@@ -15,9 +15,6 @@ from third_party.handlebar import Handlebar
# TODO(kalman): rename this HTMLDataSource or other, then have separate intro
# article data sources created as instances of it.
-# Increment this if the data model changes for IntroDataSource.
-_VERSION = 5
-
_H1_REGEX = re.compile('<h1[^>.]*?>.*?</h1>', flags=re.DOTALL)
class _IntroParser(HTMLParser):
@@ -69,8 +66,7 @@ class IntroDataSource(object):
class Factory(object):
def __init__(self, compiled_fs_factory, ref_resolver_factory, base_paths):
self._cache = compiled_fs_factory.Create(self._MakeIntroDict,
- IntroDataSource,
- version=_VERSION)
+ IntroDataSource)
self._ref_resolver = ref_resolver_factory.Create()
self._base_paths = base_paths
diff --git a/chrome/common/extensions/docs/server2/object_store_creator.py b/chrome/common/extensions/docs/server2/object_store_creator.py
index 2c3e580..1911143 100644
--- a/chrome/common/extensions/docs/server2/object_store_creator.py
+++ b/chrome/common/extensions/docs/server2/object_store_creator.py
@@ -8,42 +8,58 @@ from persistent_object_store import PersistentObjectStore
class ObjectStoreCreator(object):
class Factory(object):
- def __init__(self, branch=None):
+ '''Creates ObjectStoreCreators (yes seriously) bound to an SVN branch.
+ '''
+ def __init__(self, app_version, branch):
+ self._app_version = app_version
self._branch = branch
- '''Creates ObjectStoreCreators (yes seriously) bound to an SVN branch.
+ def Create(self, cls, store_type=None):
+ return ObjectStoreCreator(cls,
+ self._app_version,
+ self._branch,
+ store_type=store_type)
+
+ class SharedFactory(object):
+ '''A |Factory| for creating object stores shared across branches.
'''
+ def __init__(self, app_version):
+ self._factory = ObjectStoreCreator.Factory(app_version, 'shared')
+
+ def Create(self, cls, store_type=None):
+ return self._factory.Create(cls, store_type=store_type)
+
+ class TestFactory(object):
+ '''A |Factory| for creating object stores for tests, with fake defaults.
+ '''
+ def __init__(self):
+ self._factory = ObjectStoreCreator.Factory('test-version', 'test-branch')
+
def Create(self, cls, store_type=None):
- return ObjectStoreCreator(cls, branch=self._branch, store_type=store_type)
+ return self._factory.Create(cls, store_type=store_type)
- def __init__(self, cls, branch=None, store_type=None):
+ def __init__(self, cls, app_version, branch, store_type=None):
'''Creates stores with a top-level namespace given by the name of |cls|
combined with |branch|. Set an explicit |store_type| if necessary for tests.
By convention this should be the name of the class which owns the object
- store. If a class needs multiple object store it should use Create with the
+ store. If a class needs multiple object stores it should use Create with the
|category| argument.
'''
assert isinstance(cls, type)
assert not cls.__name__[0].islower() # guard against non-class types
- if branch is None:
- self._name = cls.__name__
- else:
- self._name = '%s@%s' % (cls.__name__, branch)
+ self._name = '%s/%s@%s' % (app_version, cls.__name__, branch)
self._store_type = store_type
- def Create(self, version=None, category=None):
+ def Create(self, category=None):
'''Creates a new object store with the top namespace given in the
- constructor, at version |version|, with an optional |category| for classes
- that need multiple object stores (e.g. one for stat and one for read).
+ constructor with an optional |category| for classes that need multiple
+ object stores (e.g. one for stat and one for read).
'''
namespace = self._name
if category is not None:
assert not any(c.isdigit() for c in category)
namespace = '%s/%s' % (namespace, category)
- if version is not None:
- assert isinstance(version, int)
- namespace = '%s/%s' % (namespace, version)
if self._store_type is not None:
return self._store_type(namespace)
return CacheChainObjectStore((MemcacheObjectStore(namespace),
diff --git a/chrome/common/extensions/docs/server2/object_store_creator_test.py b/chrome/common/extensions/docs/server2/object_store_creator_test.py
index 808bef9..41f552c 100755
--- a/chrome/common/extensions/docs/server2/object_store_creator_test.py
+++ b/chrome/common/extensions/docs/server2/object_store_creator_test.py
@@ -13,37 +13,27 @@ class _FooClass(object):
class ObjectStoreCreatorTest(unittest.TestCase):
def setUp(self):
- self.creator = ObjectStoreCreator(_FooClass, store_type=TestObjectStore)
+ self.creator = ObjectStoreCreator(_FooClass,
+ '3-0',
+ 'test',
+ store_type=TestObjectStore)
def testVanilla(self):
store = self.creator.Create()
- self.assertEqual('_FooClass', store.namespace)
-
- def testWithVersion(self):
- store = self.creator.Create(version=42)
- self.assertEqual('_FooClass/42', store.namespace)
+ self.assertEqual('3-0/_FooClass@test', store.namespace)
def testWithCategory(self):
store = self.creator.Create(category='cat')
- self.assertEqual('_FooClass/cat', store.namespace)
-
- def testWithVersionAndCategory(self):
- store = self.creator.Create(version=43, category='mat')
- self.assertEqual('_FooClass/mat/43', store.namespace)
+ self.assertEqual('3-0/_FooClass@test/cat', store.namespace)
- def testIllegalIinput(self):
+ def testIllegalInput(self):
self.assertRaises(AssertionError, self.creator.Create, category='5')
self.assertRaises(AssertionError, self.creator.Create, category='forty2')
- self.assertRaises(AssertionError, self.creator.Create, version='twenty')
- self.assertRaises(AssertionError, self.creator.Create, version='7a')
def testFactoryWithBranch(self):
- store = ObjectStoreCreator.Factory().Create(
- _FooClass, store_type=TestObjectStore).Create()
- self.assertEqual('_FooClass', store.namespace)
- store = ObjectStoreCreator.Factory(branch='dev').Create(
+ store = ObjectStoreCreator.Factory('3-0', 'dev').Create(
_FooClass, store_type=TestObjectStore).Create()
- self.assertEqual('_FooClass@dev', store.namespace)
+ self.assertEqual('3-0/_FooClass@dev', store.namespace)
if __name__ == '__main__':
unittest.main()
diff --git a/chrome/common/extensions/docs/server2/offline_file_system.py b/chrome/common/extensions/docs/server2/offline_file_system.py
index 281ef5dd..a48cda0 100644
--- a/chrome/common/extensions/docs/server2/offline_file_system.py
+++ b/chrome/common/extensions/docs/server2/offline_file_system.py
@@ -17,12 +17,7 @@ class OfflineFileSystem(FileSystem):
def Stat(self, path):
raise FileNotFoundError('File system is offline, cannot read %s' % path)
- # HACK: despite GetName/GetVersion being @classmethods, these need to be
- # instance methods so that we can grab the name and version from the class
- # given on construction.
-
+ # HACK: despite GetName being a @classmethod, these need to be instance
+ # methods so that we can grab the name from the class given on construction.
def GetName(self):
return self._cls.GetName()
-
- def GetVersion(self):
- return self._cls.GetVersion()
diff --git a/chrome/common/extensions/docs/server2/path_canonicalizer_test.py b/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
index 9504995..583f265 100755
--- a/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
+++ b/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
@@ -26,7 +26,7 @@ class PathCanonicalizerTest(unittest.TestCase):
test_fs = TestFileSystem(_TEST_DATA)
compiled_fs_factory = CompiledFileSystem.Factory(
test_fs,
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
self._path_canonicalizer = PathCanonicalizer('stable', compiled_fs_factory)
def _assertIdentity(self, path):
diff --git a/chrome/common/extensions/docs/server2/samples_data_source.py b/chrome/common/extensions/docs/server2/samples_data_source.py
index 897d9bd..da2d898 100644
--- a/chrome/common/extensions/docs/server2/samples_data_source.py
+++ b/chrome/common/extensions/docs/server2/samples_data_source.py
@@ -15,9 +15,6 @@ import url_constants
DEFAULT_ICON_PATH = '/images/sample-default-icon.png'
-# Increment this if the data model changes for SamplesDataSource.
-_VERSION = 4
-
class SamplesDataSource(object):
"""Constructs a list of samples and their respective files and api calls.
"""
@@ -42,8 +39,7 @@ class SamplesDataSource(object):
fs,
object_store_creator_factory).Create(fn,
SamplesDataSource,
- category=category,
- version=_VERSION)
+ category=category)
self._extensions_cache = create_compiled_fs(extensions_file_system,
self._MakeSamplesList,
'extensions')
diff --git a/chrome/common/extensions/docs/server2/server_instance.py b/chrome/common/extensions/docs/server2/server_instance.py
index 54550b3..b2b059e 100644
--- a/chrome/common/extensions/docs/server2/server_instance.py
+++ b/chrome/common/extensions/docs/server2/server_instance.py
@@ -11,6 +11,7 @@ from api_data_source import APIDataSource
from api_list_data_source import APIListDataSource
from appengine_blobstore import AppEngineBlobstore
from appengine_url_fetcher import AppEngineUrlFetcher
+from appengine_wrappers import GetAppVersion
from branch_utility import BranchUtility
from caching_file_system import CachingFileSystem
from compiled_file_system import CompiledFileSystem
@@ -51,7 +52,8 @@ class ServerInstance(object):
'''
branch_utility = ServerInstance._GetOrCreateBranchUtility()
branch = branch_utility.GetBranchNumberForChannelName(channel)
- object_store_creator_factory = ObjectStoreCreator.Factory(branch)
+ object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(),
+ branch)
# No svn nor github file systems. Rely on the crons to fill the caches, and
# for the caches to exist.
return ServerInstance(
@@ -87,7 +89,8 @@ class ServerInstance(object):
viewvc_url = svn_url.replace(url_constants.SVN_URL,
url_constants.VIEWVC_URL)
- object_store_creator_factory = ObjectStoreCreator.Factory(branch)
+ object_store_creator_factory = ObjectStoreCreator.Factory(GetAppVersion(),
+ branch)
svn_file_system = CachingFileSystem(
SubversionFileSystem(AppEngineUrlFetcher(svn_url),
@@ -102,7 +105,7 @@ class ServerInstance(object):
@staticmethod
def CreateForTest(file_system):
return ServerInstance('test',
- ObjectStoreCreator.Factory('test'),
+ ObjectStoreCreator.TestFactory(),
file_system,
None)
diff --git a/chrome/common/extensions/docs/server2/sidenav_data_source.py b/chrome/common/extensions/docs/server2/sidenav_data_source.py
index 6793456..f340eb8 100644
--- a/chrome/common/extensions/docs/server2/sidenav_data_source.py
+++ b/chrome/common/extensions/docs/server2/sidenav_data_source.py
@@ -9,9 +9,6 @@ import logging
import compiled_file_system as compiled_fs
from third_party.json_schema_compiler.model import UnixName
-# Increment this if the data model changes for SidenavDataSource.
-_VERSION = 1
-
class SidenavDataSource(object):
"""This class reads in and caches a JSON file representing the side navigation
menu.
@@ -19,8 +16,7 @@ class SidenavDataSource(object):
class Factory(object):
def __init__(self, compiled_fs_factory, json_path):
self._cache = compiled_fs_factory.Create(self._CreateSidenavDict,
- SidenavDataSource,
- version=_VERSION)
+ SidenavDataSource)
self._json_path = json_path
def Create(self, path):
diff --git a/chrome/common/extensions/docs/server2/sidenav_data_source_test.py b/chrome/common/extensions/docs/server2/sidenav_data_source_test.py
index 65fb300..3883e5f 100755
--- a/chrome/common/extensions/docs/server2/sidenav_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/sidenav_data_source_test.py
@@ -19,7 +19,7 @@ class SamplesDataSourceTest(unittest.TestCase):
'sidenav_data_source')
self._compiled_fs_factory = CompiledFileSystem.Factory(
LocalFileSystem(self._base_path),
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
def _CheckLevels(self, items, level=2):
for item in items:
diff --git a/chrome/common/extensions/docs/server2/subversion_file_system.py b/chrome/common/extensions/docs/server2/subversion_file_system.py
index 66770fe..9592e2b 100644
--- a/chrome/common/extensions/docs/server2/subversion_file_system.py
+++ b/chrome/common/extensions/docs/server2/subversion_file_system.py
@@ -9,14 +9,6 @@ import re
import xml.dom.minidom as xml
from xml.parsers.expat import ExpatError
-# Sometimes we get bad data and end up caching it. Increment this so that
-# CachingFileSystem (if one is attached) knows to re-fetch.
-#
-# WARNING: This is a VERY EXPENSIVE number to bump. ONLY do so if the data
-# returned by these operations changes, DESPITE WHAT THE PRESUBMIT WARNING
-# MIGHT TELL YOU!
-_VERSION = 1
-
class _AsyncFetchFuture(object):
def __init__(self, paths, fetcher, binary):
# A list of tuples of the form (path, Future).
@@ -134,7 +126,3 @@ class SubversionFileSystem(FileSystem):
raise FileNotFoundError('%s was not in child versions' % filename)
stat_info.version = stat_info.child_versions[filename]
return stat_info
-
- @classmethod
- def GetVersion(cls):
- return _VERSION
diff --git a/chrome/common/extensions/docs/server2/template_data_source.py b/chrome/common/extensions/docs/server2/template_data_source.py
index e7c86b3..7185d4d 100644
--- a/chrome/common/extensions/docs/server2/template_data_source.py
+++ b/chrome/common/extensions/docs/server2/template_data_source.py
@@ -12,9 +12,6 @@ from file_system import FileNotFoundError
from third_party.handlebar import Handlebar
import url_constants
-# Increment this if the data model changes for TemplateDataSource.
-_VERSION = 3
-
EXTENSIONS_URL = '/chrome/extensions'
def _MakeChannelDict(channel_name):
@@ -61,8 +58,7 @@ class TemplateDataSource(object):
self._samples_data_source_factory = samples_data_source_factory
self._sidenav_data_source_factory = sidenav_data_source_factory
self._cache = compiled_fs_factory.Create(self._CreateTemplate,
- TemplateDataSource,
- version=_VERSION)
+ TemplateDataSource)
self._ref_resolver = ref_resolver_factory.Create()
self._public_template_path = public_template_path
self._private_template_path = private_template_path
diff --git a/chrome/common/extensions/docs/server2/template_data_source_test.py b/chrome/common/extensions/docs/server2/template_data_source_test.py
index 4765e74..813f2fd 100755
--- a/chrome/common/extensions/docs/server2/template_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/template_data_source_test.py
@@ -58,7 +58,7 @@ class TemplateDataSourceTest(unittest.TestCase):
reference_resolver_factory = ReferenceResolver.Factory(
api_data_factory,
self._fake_api_list_data_source_factory,
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
return (TemplateDataSource.Factory('fake_channel',
api_data_factory,
self._fake_api_list_data_source_factory,
@@ -76,9 +76,10 @@ class TemplateDataSourceTest(unittest.TestCase):
fetcher = LocalFileSystem(self._base_path)
compiled_fs_factory = CompiledFileSystem.Factory(
fetcher,
- ObjectStoreCreator.Factory())
- t_data_source = self._CreateTemplateDataSource(compiled_fs_factory,
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
+ t_data_source = self._CreateTemplateDataSource(
+ compiled_fs_factory,
+ ObjectStoreCreator.TestFactory())
template_a1 = Handlebar(self._ReadLocalFile('test1.html'))
self.assertEqual(template_a1.render({}, {'templates': {}}).text,
t_data_source.get('test1').render({}, {'templates': {}}).text)
@@ -94,7 +95,7 @@ class TemplateDataSourceTest(unittest.TestCase):
fetcher = LocalFileSystem(self._base_path)
compiled_fs_factory = CompiledFileSystem.Factory(
fetcher,
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
t_data_source = self._CreateTemplateDataSource(compiled_fs_factory)
self.assertEqual(
self._ReadLocalFile('test_expected.html'),
@@ -107,7 +108,7 @@ class TemplateDataSourceTest(unittest.TestCase):
context = json.loads(self._ReadLocalFile('test1.json'))
compiled_fs_factory = CompiledFileSystem.Factory(
fetcher,
- ObjectStoreCreator.Factory())
+ ObjectStoreCreator.TestFactory())
self._RenderTest(
'test1',
self._CreateTemplateDataSource(