add TIRAMISU_STORAGE environment variable
This commit is contained in:
parent
b64189f763
commit
3cc2d9ca3d
2 changed files with 13 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jun 20 16:27:55 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
|
||||
* add TIRAMISU_STORAGE for personalise default storage in
|
||||
environnement
|
||||
|
||||
Thu Jun 19 23:20:29 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
|
||||
* add DynOptionDescription:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue