From 5bba657a8438f4ab267cc19feb68f0f4494d3ee0 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 30 Dec 2013 14:06:38 -0800 Subject: [PATCH] Add stronger checking of backend configuration Set a default if the backend configuration is not provided as well as check for the configuration being a dictionary instead of any arbitary non-false type. Change-Id: Id458ac0eb2d7b86c5602ed2f23a52fb2c6f6f0e7 --- taskflow/persistence/backends/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/taskflow/persistence/backends/base.py b/taskflow/persistence/backends/base.py index e0c6f27d..1f76aeab 100644 --- a/taskflow/persistence/backends/base.py +++ b/taskflow/persistence/backends/base.py @@ -26,6 +26,11 @@ class Backend(object): """Base class for persistence backends.""" def __init__(self, conf): + if not conf: + conf = {} + if not isinstance(conf, dict): + raise TypeError("Configuration dictionary expected not: %s" + % type(conf)) self._conf = conf @abc.abstractmethod