OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from appengine_wrappers import GetAppVersion | 5 from appengine_wrappers import GetAppVersion |
6 from cache_chain_object_store import CacheChainObjectStore | 6 from cache_chain_object_store import CacheChainObjectStore |
7 from memcache_object_store import MemcacheObjectStore | 7 from memcache_object_store import MemcacheObjectStore |
8 from test_object_store import TestObjectStore | 8 from test_object_store import TestObjectStore |
9 from persistent_object_store import PersistentObjectStore | 9 from persistent_object_store import PersistentObjectStore |
10 | 10 |
11 _unspecified = object() | 11 _unspecified = object() |
12 | 12 |
13 class ObjectStoreCreator(object): | 13 class ObjectStoreCreator(object): |
14 '''Creates ObjectStores with a namespacing and behaviour configuration. | 14 '''Creates ObjectStores with a namespacing and behaviour configuration. |
15 | 15 |
16 The initial configuration is specified on object store construction. When | 16 The initial configuration is specified on object store construction. When |
17 creating ObjectStores via Create this configuration can be overridden (or | 17 creating ObjectStores via Create this configuration can be overridden (or |
18 via the variants of Create which do this automatically). | 18 via the variants of Create which do this automatically). |
19 ''' | 19 ''' |
20 def __init__(self, | 20 def __init__(self, |
21 channel, | 21 channel, |
| 22 # TODO(kalman): rename start_dirty? |
22 start_empty=_unspecified, | 23 start_empty=_unspecified, |
23 # Override for testing. A custom ObjectStore type to construct | 24 # Override for testing. A custom ObjectStore type to construct |
24 # on Create(). Useful with TestObjectStore, for example. | 25 # on Create(). Useful with TestObjectStore, for example. |
25 store_type=None, | 26 store_type=None, |
26 # Override for testing. Whether the ObjectStore type specified | 27 # Override for testing. Whether the ObjectStore type specified |
27 # with |store_type| should be wrapped e.g. with Caching. This is | 28 # with |store_type| should be wrapped e.g. with Caching. This is |
28 # useful to override when specific state tests/manipulations are | 29 # useful to override when specific state tests/manipulations are |
29 # being done on the underlying object store. | 30 # being done on the underlying object store. |
30 disable_wrappers=False): | 31 disable_wrappers=False): |
31 self._channel = channel | 32 self._channel = channel |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if value is not None) | 78 if value is not None) |
78 | 79 |
79 if self._disable_wrappers: | 80 if self._disable_wrappers: |
80 return self._store_type(namespace, start_empty=start_empty) | 81 return self._store_type(namespace, start_empty=start_empty) |
81 | 82 |
82 if self._store_type is not None: | 83 if self._store_type is not None: |
83 chain = (self._store_type(namespace),) | 84 chain = (self._store_type(namespace),) |
84 else: | 85 else: |
85 chain = (MemcacheObjectStore(namespace), PersistentObjectStore(namespace)) | 86 chain = (MemcacheObjectStore(namespace), PersistentObjectStore(namespace)) |
86 return CacheChainObjectStore(chain, start_empty=start_empty) | 87 return CacheChainObjectStore(chain, start_empty=start_empty) |
OLD | NEW |