diff --git a/ChangeLog b/ChangeLog index 481e8ba..cf73539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jun 20 16:27:55 2014 +0200 Emmanuel Garette + + * add TIRAMISU_STORAGE for personalise default storage in + environnement + Thu Jun 19 23:20:29 2014 +0200 Emmanuel Garette * add DynOptionDescription: diff --git a/tiramisu/storage/__init__.py b/tiramisu/storage/__init__.py index 3cba5c6..5bb0ec8 100644 --- a/tiramisu/storage/__init__.py +++ b/tiramisu/storage/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Team tiramisu (see AUTHORS for all contributors) +# Copyright (C) 2013-2014 Team tiramisu (see AUTHORS for all contributors) # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the @@ -27,6 +27,7 @@ configurator ``set_storage()``. from time import time +import os from tiramisu.error import ConfigError from tiramisu.i18n import _ @@ -36,7 +37,7 @@ class StorageType(object): default storage is store as selected storage. You cannot change it after. """ - default_storage = 'dictionary' + default_storage = os.environ.get('TIRAMISU_STORAGE', 'dictionary') storage_type = None mod = None @@ -52,7 +53,11 @@ class StorageType(object): self.storage_type = self.default_storage if self.mod is None: modulepath = 'tiramisu.storage.{0}'.format(self.storage_type) - mod = __import__(modulepath) + try: + mod = __import__(modulepath) + except ImportError: + raise SystemError(_('cannot import the storage {0}').format( + self.default_storage)) for token in modulepath.split(".")[1:]: mod = getattr(mod, token) self.mod = mod