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

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

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/object_store_creator.py
===================================================================
--- chrome/common/extensions/docs/server2/object_store_creator.py (revision 196927)
+++ chrome/common/extensions/docs/server2/object_store_creator.py (working copy)
@@ -13,18 +13,30 @@
namespace for the object stores that are created.
- |start_empty| Whether the caching object store that gets created should
start empty, or start with the content of its delegate object stores.
+ - |persistent| Whether the caching object store is persistent.
+ - |more| A dictionary containing other information to include in the
+ namespace.
'''
- def __init__(self, app_version, branch, start_empty=False):
+ def __init__(self,
+ app_version,
+ branch,
+ start_empty=False,
+ persistent=True,
not at google - send to devlin 2013/04/30 15:37:42 I was wondering, it actually seems fine to just pe
方觉(Fang Jue) 2013/05/01 15:27:25 Since you say it's fine, then I'll use persistent
+ more=None):
self._app_version = app_version
self._branch = branch
self._start_empty = start_empty
+ self._persistent = persistent
+ self._more = more
def Create(self, cls, store_type=None):
return ObjectStoreCreator(cls,
self._app_version,
self._branch,
store_type=store_type,
- start_empty=self._start_empty)
+ start_empty=self._start_empty,
+ persistent=self._persistent,
+ more=self._more)
class SharedFactory(object):
'''A |Factory| for creating object stores shared across branches.
@@ -49,7 +61,9 @@
app_version,
branch,
store_type=None,
- start_empty=False):
+ start_empty=False,
+ persistent=True,
+ more=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.
@@ -59,9 +73,18 @@
'''
assert isinstance(cls, type)
assert not cls.__name__[0].islower() # guard against non-class types
- self._name = '%s/%s@%s' % (app_version, cls.__name__, branch)
+ _components = {
+ 'version': app_version,
+ 'branch': branch,
+ 'cls': cls.__name__,
+ }
+ if more:
+ _components.update(more)
+ self._name = '/'.join('%s=%s' % (key, _components[key])
+ for key in sorted(_components.keys()))
self._store_type = store_type
self._start_empty = start_empty
+ self._persistent = persistent
def Create(self, category=None):
'''Creates a new object store with the top namespace given in the
@@ -74,6 +97,7 @@
namespace = '%s/%s' % (namespace, category)
if self._store_type is not None:
return self._store_type(namespace)
- return CacheChainObjectStore(
- (MemcacheObjectStore(namespace), PersistentObjectStore(namespace)),
- start_empty=self._start_empty)
+ object_stores = (MemcacheObjectStore(namespace),)
+ if self._persistent:
+ object_stores += (PersistentObjectStore(namespace),)
not at google - send to devlin 2013/04/30 15:37:42 fwiw, if you're modifying lists, use a list not a
+ return CacheChainObjectStore(object_stores, start_empty=self._start_empty)

Powered by Google App Engine
This is Rietveld 408576698