summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-06-10 18:10:57 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-06-10 18:10:57 -0700
commitad296327136015b03f5e3d95234e79972f99d9f7 (patch)
tree682ce9789b146b9f170ebee538e37cd5a6b28450
parent4c36d389997606c1c5d38dcff42302fd6b9dd479 (diff)
downloadtaskflow-ad296327136015b03f5e3d95234e79972f99d9f7.tar.gz
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
-rw-r--r--taskflow/persistence/backends/impl_memory.py6
-rw-r--r--taskflow/persistence/backends/impl_zookeeper.py6
-rw-r--r--taskflow/persistence/path_based.py5
3 files changed, 13 insertions, 4 deletions
diff --git a/taskflow/persistence/backends/impl_memory.py b/taskflow/persistence/backends/impl_memory.py
index 43207b8..c18b471 100644
--- a/taskflow/persistence/backends/impl_memory.py
+++ b/taskflow/persistence/backends/impl_memory.py
@@ -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()
diff --git a/taskflow/persistence/backends/impl_zookeeper.py b/taskflow/persistence/backends/impl_zookeeper.py
index 279e0c6..687f103 100644
--- a/taskflow/persistence/backends/impl_zookeeper.py
+++ b/taskflow/persistence/backends/impl_zookeeper.py
@@ -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:
diff --git a/taskflow/persistence/path_based.py b/taskflow/persistence/path_based.py
index 6c065df..0d72997 100644
--- a/taskflow/persistence/path_based.py
+++ b/taskflow/persistence/path_based.py
@@ -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):