Use a class constant for the default path based backend path

When no path is provided to a path based backend via configuration
use a class constant to provide the default, and override this in
backends that support providing defaults.

Change-Id: I0a6c88398403a162b113e34abe7e56821d1f02bc
This commit is contained in:
Joshua Harlow 2015-06-10 18:10:57 -07:00
parent 4c36d38999
commit ad29632713
3 changed files with 13 additions and 4 deletions

View File

@ -309,10 +309,12 @@ class MemoryBackend(path_based.PathBasedBackend):
guarantee that there will be no inter-thread race conditions when
writing and reading by using a read/write locks.
"""
#: Default path used when none is provided.
DEFAULT_PATH = pp.sep
def __init__(self, conf=None):
super(MemoryBackend, self).__init__(conf)
if self._path is None:
self._path = pp.sep
self.memory = FakeFilesystem(deep_copy=self._conf.get('deep_copy',
True))
self.lock = fasteners.ReaderWriterLock()

View File

@ -40,10 +40,12 @@ class ZkBackend(path_based.PathBasedBackend):
"path": "/taskflow",
}
"""
#: Default path used when none is provided.
DEFAULT_PATH = '/taskflow'
def __init__(self, conf, client=None):
super(ZkBackend, self).__init__(conf)
if not self._path:
self._path = '/taskflow'
if not paths.isabs(self._path):
raise ValueError("Zookeeper path must be absolute")
if client is not None:

View File

@ -34,9 +34,14 @@ class PathBasedBackend(base.Backend):
the contents of those objects for later reading and writing.
"""
#: Default path used when none is provided.
DEFAULT_PATH = None
def __init__(self, conf):
super(PathBasedBackend, self).__init__(conf)
self._path = self._conf.get('path', None)
if not self._path:
self._path = self.DEFAULT_PATH
@property
def path(self):