we can personalise storage easily

This commit is contained in:
Emmanuel Garette 2013-08-20 09:47:12 +02:00
parent df7d6759cd
commit e826f3d1c6
12 changed files with 237 additions and 242 deletions

View File

@ -20,13 +20,13 @@ def test_cache():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u2 c.u2
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
assert od1.u2 in values._p_get_cached('value') assert od1.u2 in values._p_.get_cached('value', c)
assert od1.u2 in settings._p_get_cached('property') assert od1.u2 in settings._p_.get_cached('property', c)
def test_cache_reset(): def test_cache_reset():
@ -36,44 +36,44 @@ def test_cache_reset():
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
#when change a value #when change a value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u2 = 1 c.u2 = 1
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when remove a value #when remove a value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
del(c.u2) del(c.u2)
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when add/del property #when add/del property
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_get_settings()[od1.u2].append('test') c.cfgimpl_get_settings()[od1.u2].append('test')
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_get_settings()[od1.u2].remove('test') c.cfgimpl_get_settings()[od1.u2].remove('test')
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when enable/disabled property #when enable/disabled property
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_get_settings().append('test') c.cfgimpl_get_settings().append('test')
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_get_settings().remove('test') c.cfgimpl_get_settings().remove('test')
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
def test_cache_reset_multi(): def test_cache_reset_multi():
@ -83,32 +83,32 @@ def test_cache_reset_multi():
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
#when change a value #when change a value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u3 = [1] c.u3 = [1]
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when append value #when append value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u3.append(1) c.u3.append(1)
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when pop value #when pop value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u3.pop(1) c.u3.pop(1)
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
#when remove a value #when remove a value
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
del(c.u3) del(c.u3)
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
def test_reset_cache(): def test_reset_cache():
@ -117,23 +117,23 @@ def test_reset_cache():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache() c.cfgimpl_reset_cache()
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
c.u1 c.u1
sleep(1) sleep(1)
c.u2 c.u2
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
assert od1.u2 in values._p_get_cached('value') assert od1.u2 in values._p_.get_cached('value', c)
assert od1.u2 in settings._p_get_cached('property') assert od1.u2 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache() c.cfgimpl_reset_cache()
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
assert od1.u2 not in values._p_get_cached('value') assert od1.u2 not in values._p_.get_cached('value', c)
assert od1.u2 not in settings._p_get_cached('property') assert od1.u2 not in settings._p_.get_cached('property', c)
def test_reset_cache_only_expired(): def test_reset_cache_only_expired():
@ -142,22 +142,22 @@ def test_reset_cache_only_expired():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
sleep(1) sleep(1)
c.u2 c.u2
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
assert od1.u2 in values._p_get_cached('value') assert od1.u2 in values._p_.get_cached('value', c)
assert od1.u2 in settings._p_get_cached('property') assert od1.u2 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)
assert od1.u2 in values._p_get_cached('value') assert od1.u2 in values._p_.get_cached('value', c)
assert od1.u2 in settings._p_get_cached('property') assert od1.u2 in settings._p_.get_cached('property', c)
def test_reset_cache_only(): def test_reset_cache_only():
@ -166,14 +166,14 @@ def test_reset_cache_only():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache(only=('values',)) c.cfgimpl_reset_cache(only=('values',))
assert od1.u1 not in values._p_get_cached('value') assert od1.u1 not in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.u1 c.u1
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 in settings._p_get_cached('property') assert od1.u1 in settings._p_.get_cached('property', c)
c.cfgimpl_reset_cache(only=('settings',)) c.cfgimpl_reset_cache(only=('settings',))
assert od1.u1 in values._p_get_cached('value') assert od1.u1 in values._p_.get_cached('value', c)
assert od1.u1 not in settings._p_get_cached('property') assert od1.u1 not in settings._p_.get_cached('property', c)

View File

@ -327,23 +327,23 @@ def test_reset_properties():
cfg = Config(descr) cfg = Config(descr)
setting = cfg.cfgimpl_get_settings() setting = cfg.cfgimpl_get_settings()
option = cfg.cfgimpl_get_description().gc.dummy option = cfg.cfgimpl_get_description().gc.dummy
assert setting._p_get_properties() == {} assert setting._p_.get_properties(cfg) == {}
setting.append('frozen') setting.append('frozen')
assert setting._p_get_properties() == {None: set(('frozen', 'expire', 'validator'))} assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator'))}
setting.reset() setting.reset()
assert setting._p_get_properties() == {} assert setting._p_.get_properties(cfg) == {}
setting[option].append('test') setting[option].append('test')
assert setting._p_get_properties() == {option: set(('test',))} assert setting._p_.get_properties(cfg) == {option: set(('test',))}
setting.reset() setting.reset()
assert setting._p_get_properties() == {option: set(('test',))} assert setting._p_.get_properties(cfg) == {option: set(('test',))}
setting.append('frozen') setting.append('frozen')
assert setting._p_get_properties() == {None: set(('frozen', 'expire', 'validator')), option: set(('test',))} assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator')), option: set(('test',))}
setting.reset(option) setting.reset(option)
assert setting._p_get_properties() == {None: set(('frozen', 'expire', 'validator'))} assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator'))}
setting[option].append('test') setting[option].append('test')
assert setting._p_get_properties() == {None: set(('frozen', 'expire', 'validator')), option: set(('test',))} assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator')), option: set(('test',))}
setting.reset(all_properties=True) setting.reset(all_properties=True)
assert setting._p_get_properties() == {} assert setting._p_.get_properties(cfg) == {}
raises(ValueError, 'setting.reset(all_properties=True, opt=option)') raises(ValueError, 'setting.reset(all_properties=True, opt=option)')

View File

@ -20,10 +20,11 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
from time import time
from tiramisu.error import PropertiesOptionError, ConfigError from tiramisu.error import PropertiesOptionError, ConfigError
from tiramisu.option import OptionDescription, Option, SymLinkOption, \ from tiramisu.option import OptionDescription, Option, SymLinkOption, \
BaseInformation BaseInformation
from tiramisu.setting import groups, Settings, default_encoding from tiramisu.setting import groups, Settings, default_encoding, default_storage
from tiramisu.value import Values from tiramisu.value import Values
from tiramisu.i18n import _ from tiramisu.i18n import _
@ -505,9 +506,9 @@ class Config(CommonConfig):
:param context: the current root config :param context: the current root config
:type context: `Config` :type context: `Config`
""" """
config_id = str(id(self)) config_id = str(id(self)) + str(time())
self._impl_settings = Settings(self, config_id) self._impl_settings = Settings(self, config_id, default_storage)
self._impl_values = Values(self, config_id) self._impl_values = Values(self, config_id, default_storage)
super(Config, self).__init__(descr, self) super(Config, self).__init__(descr, self)
self._impl_build_all_paths() self._impl_build_all_paths()
self._impl_meta = None self._impl_meta = None
@ -543,8 +544,8 @@ class MetaConfig(CommonConfig):
config_id = str(id(self)) config_id = str(id(self))
self._impl_children = children self._impl_children = children
self._impl_settings = Settings(self, config_id) self._impl_settings = Settings(self, config_id, default_storage)
self._impl_values = Values(self, config_id) self._impl_values = Values(self, config_id, default_storage)
self._impl_meta = None self._impl_meta = None
self._impl_informations = {} self._impl_informations = {}

View File

@ -59,7 +59,7 @@ class BaseInformation(object):
def impl_set_information(self, key, value): def impl_set_information(self, key, value):
"""updates the information's attribute """updates the information's attribute
(wich is a dictionnary) (which is a dictionary)
:param key: information's key (ex: "help", "doc" :param key: information's key (ex: "help", "doc"
:param value: information's value (ex: "the help string") :param value: information's value (ex: "the help string")

View File

@ -19,35 +19,36 @@
# ____________________________________________________________ # ____________________________________________________________
class PluginCache(object): class Cache(object):
__slots__ = ('_cache',) __slots__ = ('_cache',)
key_is_path = False
def __init__(self): def __init__(self):
self._cache = {} self._cache = {}
def _p_setcache(self, cache_type, opt, val, time): def setcache(self, cache_type, opt, val, time):
self._cache[opt] = (val, time) self._cache[opt] = (val, time)
def _p_getcache(self, cache_type, opt, exp): def getcache(self, cache_type, opt, exp):
value, created = self._cache[opt] value, created = self._cache[opt]
if exp < created: if exp < created:
return True, value return True, value
return False, None return False, None
def _p_hascache(self, cache_type, opt): def hascache(self, cache_type, opt):
return opt in self._cache return opt in self._cache
def _p_reset_expired_cache(self, cache_type, exp): def reset_expired_cache(self, cache_type, exp):
keys = self._cache.keys() keys = self._cache.keys()
for key in keys: for key in keys:
val, created = self._cache[key] val, created = self._cache[key]
if exp > created: if exp > created:
del(self._cache[key]) del(self._cache[key])
def _p_reset_all_cache(self, cache_type): def reset_all_cache(self, cache_type):
self._cache.clear() self._cache.clear()
def _p_get_cached(self, cache_type): def get_cached(self, cache_type, context):
"""return all values in a dictionary """return all values in a dictionary
example: {option1: ('value1', 'time1'), option2: ('value2', 'time2')} example: {option1: ('value1', 'time1'), option2: ('value2', 'time2')}
""" """

View File

@ -17,10 +17,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# ____________________________________________________________ # ____________________________________________________________
from tiramisu.plugins.dictionary.cache import PluginCache from tiramisu.plugins.dictionary.cache import Cache
class PluginSettings(PluginCache): class Settings(Cache):
__slots__ = ('_properties', '_permissives') __slots__ = ('_properties', '_permissives')
def __init__(self, config_id): def __init__(self, config_id):
@ -29,33 +29,33 @@ class PluginSettings(PluginCache):
self._properties = {} self._properties = {}
# permissive properties # permissive properties
self._permissives = {} self._permissives = {}
super(PluginSettings, self).__init__() super(Settings, self).__init__()
# propertives # propertives
def _p_setproperties(self, opt, properties): def setproperties(self, opt, properties):
self._properties[opt] = properties self._properties[opt] = properties
def _p_getproperties(self, opt, default_properties): def getproperties(self, opt, default_properties):
return self._properties.get(opt, set(default_properties)) return self._properties.get(opt, set(default_properties))
def _p_hasproperties(self, opt): def hasproperties(self, opt):
return opt in self._properties return opt in self._properties
def _p_reset_all_propertives(self): def reset_all_propertives(self):
self._properties.clear() self._properties.clear()
def _p_reset_properties(self, opt): def reset_properties(self, opt):
try: try:
del(self._properties[opt]) del(self._properties[opt])
except KeyError: except KeyError:
pass pass
def _p_get_properties(self, cache_type): def get_properties(self, context):
return self._properties return self._properties
# permissive # permissive
def _p_setpermissive(self, opt, permissive): def setpermissive(self, opt, permissive):
self._permissives[opt] = frozenset(permissive) self._permissives[opt] = frozenset(permissive)
def _p_getpermissive(self, opt=None): def getpermissive(self, opt=None):
return self._permissives.get(opt, frozenset()) return self._permissives.get(opt, frozenset())

View File

@ -19,10 +19,10 @@
# ____________________________________________________________ # ____________________________________________________________
#FIXME #FIXME
from tiramisu.plugins.dictionary.cache import PluginCache from tiramisu.plugins.dictionary.cache import Cache
class PluginValues(PluginCache): class Values(Cache):
__slots__ = ('_values',) __slots__ = ('_values',)
def __init__(self, config_id): def __init__(self, config_id):
@ -30,46 +30,45 @@ class PluginValues(PluginCache):
""" """
self._values = {} self._values = {}
# should init cache too # should init cache too
super(PluginValues, self).__init__() super(Values, self).__init__()
# value # value
def _p_setvalue(self, opt, value): def setvalue(self, opt, value, owner):
"""set value for an option """set value for an option
a specified value must be associated to an owner a specified value must be associated to an owner
""" """
owner = self.context.cfgimpl_get_settings().getowner()
self._values[opt] = (owner, value) self._values[opt] = (owner, value)
def _p_getvalue(self, opt): def getvalue(self, opt):
"""get value for an option """get value for an option
return: only value, not the owner return: only value, not the owner
""" """
return self._values[opt][1] return self._values[opt][1]
def _p_hasvalue(self, opt): def hasvalue(self, opt):
"""if opt has a value """if opt has a value
return: boolean return: boolean
""" """
return opt in self._values return opt in self._values
def _p_resetvalue(self, opt): def resetvalue(self, opt):
"""remove value means delete value in storage """remove value means delete value in storage
""" """
del(self._values[opt]) del(self._values[opt])
def _p_get_modified_values(self): def get_modified_values(self):
"""return all values in a dictionary """return all values in a dictionary
example: {option1: (owner, 'value1'), option2: (owner, 'value2')} example: {option1: (owner, 'value1'), option2: (owner, 'value2')}
""" """
return self._values return self._values
# owner # owner
def _p_setowner(self, opt, owner): def setowner(self, opt, owner):
"""change owner for an option """change owner for an option
""" """
self._values[opt] = (owner, self._values[opt][1]) self._values[opt] = (owner, self._values[opt][1])
def _p_getowner(self, opt, default): def getowner(self, opt, default):
"""get owner for an option """get owner for an option
return: owner object return: owner object
""" """

View File

@ -19,12 +19,12 @@
# ____________________________________________________________ # ____________________________________________________________
from pickle import dumps, loads from pickle import dumps, loads
from os import unlink
import sqlite3 import sqlite3
class PluginCache(object): class Cache(object):
__slots__ = ('_conn', '_cursor') __slots__ = ('_conn', '_cursor')
key_is_path = True
def __init__(self, config_id, cache_type): def __init__(self, config_id, cache_type):
cache_table = 'CREATE TABLE IF NOT EXISTS cache_{0}(path text primary key, value text, time real)'.format(cache_type) cache_table = 'CREATE TABLE IF NOT EXISTS cache_{0}(path text primary key, value text, time real)'.format(cache_type)
@ -34,52 +34,49 @@ class PluginCache(object):
self._cursor.execute(cache_table) self._cursor.execute(cache_table)
# value # value
def _p_sqlite_decode(self, value): def _sqlite_decode(self, value):
return loads(value) return loads(value)
def _p_sqlite_encode(self, value): def _sqlite_encode(self, value):
if isinstance(value, list): if isinstance(value, list):
value = list(value) value = list(value)
return dumps(value) return dumps(value)
def _p_setcache(self, cache_type, opt, val, time): def setcache(self, cache_type, path, val, time):
path = self._get_opt_path(opt) convert_value = self._sqlite_encode(val)
convert_value = self._p_sqlite_encode(val)
self._cursor.execute("DELETE FROM cache_{0} WHERE path = ?".format(cache_type), (path,)) self._cursor.execute("DELETE FROM cache_{0} WHERE path = ?".format(cache_type), (path,))
self._cursor.execute("INSERT INTO cache_{0}(path, value, time) VALUES (?, ?, ?)".format(cache_type), self._cursor.execute("INSERT INTO cache_{0}(path, value, time) VALUES (?, ?, ?)".format(cache_type),
(path, convert_value, time)) (path, convert_value, time))
self._conn.commit() self._conn.commit()
def _p_getcache(self, cache_type, opt, exp): def getcache(self, cache_type, path, exp):
path = self._get_opt_path(opt)
self._cursor.execute("SELECT value FROM cache_{0} WHERE path = ? AND time >= ?".format(cache_type), (path, exp)) self._cursor.execute("SELECT value FROM cache_{0} WHERE path = ? AND time >= ?".format(cache_type), (path, exp))
cached = self._cursor.fetchone() cached = self._cursor.fetchone()
if cached is None: if cached is None:
return False, None return False, None
else: else:
return True, self._p_sqlite_decode(cached[0]) return True, self._sqlite_decode(cached[0])
def _p_hascache(self, cache_type, opt): def hascache(self, cache_type, path):
path = self._get_opt_path(opt)
self._cursor.execute("SELECT value FROM cache_{0} WHERE path = ?".format(cache_type), (path,)) self._cursor.execute("SELECT value FROM cache_{0} WHERE path = ?".format(cache_type), (path,))
return self._cursor.fetchone() is not None return self._cursor.fetchone() is not None
def _p_reset_expired_cache(self, cache_type, exp): def reset_expired_cache(self, cache_type, exp):
self._cursor.execute("DELETE FROM cache_{0} WHERE time < ?".format(cache_type), (exp,)) self._cursor.execute("DELETE FROM cache_{0} WHERE time < ?".format(cache_type), (exp,))
self._conn.commit() self._conn.commit()
def _p_reset_all_cache(self, cache_type): def reset_all_cache(self, cache_type):
self._cursor.execute("DELETE FROM cache_{0}".format(cache_type)) self._cursor.execute("DELETE FROM cache_{0}".format(cache_type))
self._conn.commit() self._conn.commit()
def _p_get_cached(self, cache_type): def get_cached(self, cache_type, context):
"""return all values in a dictionary """return all values in a dictionary
example: {option1: ('value1', 'time1'), option2: ('value2', 'time2')} example: {option1: ('value1', 'time1'), option2: ('value2', 'time2')}
""" """
self._cursor.execute("SELECT * FROM cache_{0}".format(cache_type)) self._cursor.execute("SELECT * FROM cache_{0}".format(cache_type))
ret = {} ret = {}
for path, value, time in self._cursor.fetchall(): for path, value, time in self._cursor.fetchall():
opt = self.context.cfgimpl_get_description().impl_get_opt_by_path(path) opt = context.cfgimpl_get_description().impl_get_opt_by_path(path)
value = self._p_sqlite_decode(value) value = self._sqlite_decode(value)
ret[opt] = (value, time) ret[opt] = (value, time)
return ret return ret

View File

@ -17,59 +17,48 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# ____________________________________________________________ # ____________________________________________________________
from tiramisu.plugins.sqlite3.cache import PluginCache from tiramisu.plugins.sqlite3.cache import Cache
class PluginSettings(PluginCache): class Settings(Cache):
__slots__ = tuple() __slots__ = tuple()
def __init__(self, config_id): def __init__(self, config_id):
settings_table = 'CREATE TABLE IF NOT EXISTS property(path text primary key, properties text)' settings_table = 'CREATE TABLE IF NOT EXISTS property(path text primary key, properties text)'
permissives_table = 'CREATE TABLE IF NOT EXISTS permissive(path text primary key, permissives text)' permissives_table = 'CREATE TABLE IF NOT EXISTS permissive(path text primary key, permissives text)'
# should init cache too # should init cache too
super(PluginSettings, self).__init__(config_id, 'property') super(Settings, self).__init__(config_id, 'property')
self._cursor.execute(settings_table) self._cursor.execute(settings_table)
self._cursor.execute(permissives_table) self._cursor.execute(permissives_table)
self._conn.commit() self._conn.commit()
# sqlite
def _p_sqlite_getpath(self, opt):
if opt is None:
return '_none'
else:
return self._get_opt_path(opt)
# propertives # propertives
def _p_setproperties(self, opt, properties): def setproperties(self, path, properties):
path = self._p_sqlite_getpath(opt)
self._cursor.execute("DELETE FROM property WHERE path = ?", (path,)) self._cursor.execute("DELETE FROM property WHERE path = ?", (path,))
self._cursor.execute("INSERT INTO property(path, properties) VALUES (?, ?)", self._cursor.execute("INSERT INTO property(path, properties) VALUES (?, ?)",
(path, self._p_sqlite_encode(properties))) (path, self._sqlite_encode(properties)))
self._conn.commit() self._conn.commit()
def _p_getproperties(self, opt, default_properties): def getproperties(self, path, default_properties):
path = self._p_sqlite_getpath(opt)
self._cursor.execute("SELECT properties FROM property WHERE path = ?", (path,)) self._cursor.execute("SELECT properties FROM property WHERE path = ?", (path,))
value = self._cursor.fetchone() value = self._cursor.fetchone()
if value is None: if value is None:
return set(default_properties) return set(default_properties)
else: else:
return set(self._p_sqlite_decode(value[0])) return set(self._sqlite_decode(value[0]))
def _p_hasproperties(self, opt): def hasproperties(self, path):
path = self._p_sqlite_getpath(opt)
return self._cursor.execute("SELECT properties FROM property WHERE path = ?", (path,)) is not None return self._cursor.execute("SELECT properties FROM property WHERE path = ?", (path,)) is not None
def _p_reset_all_propertives(self): def reset_all_propertives(self):
self._cursor.execute("DELETE FROM property") self._cursor.execute("DELETE FROM property")
self._conn.commit() self._conn.commit()
def _p_reset_properties(self, opt): def reset_properties(self, path):
path = self._p_sqlite_getpath(opt)
self._cursor.execute("DELETE FROM property WHERE path = ?", (path,)) self._cursor.execute("DELETE FROM property WHERE path = ?", (path,))
self._conn.commit() self._conn.commit()
def _p_get_properties(self): def get_properties(self, context):
"""return all properties in a dictionary """return all properties in a dictionary
""" """
self._cursor.execute("SELECT * FROM property") self._cursor.execute("SELECT * FROM property")
@ -78,24 +67,22 @@ class PluginSettings(PluginCache):
if path == '_none': if path == '_none':
opt = None opt = None
else: else:
opt = self.context.cfgimpl_get_description().impl_get_opt_by_path(path) opt = context.cfgimpl_get_description().impl_get_opt_by_path(path)
properties = self._p_sqlite_decode(properties) properties = self._sqlite_decode(properties)
ret[opt] = properties ret[opt] = properties
return ret return ret
# permissive # permissive
def _p_setpermissive(self, opt, permissive): def setpermissive(self, path, permissive):
path = self._p_sqlite_getpath(opt)
self._cursor.execute("DELETE FROM permissive WHERE path = ?", (path,)) self._cursor.execute("DELETE FROM permissive WHERE path = ?", (path,))
self._cursor.execute("INSERT INTO permissive(path, permissives) VALUES (?, ?)", self._cursor.execute("INSERT INTO permissive(path, permissives) VALUES (?, ?)",
(path, self._p_sqlite_encode(permissive))) (path, self._sqlite_encode(permissive)))
self._conn.commit() self._conn.commit()
def _p_getpermissive(self, opt=None): def getpermissive(self, path='_none'):
path = self._p_sqlite_getpath(opt)
self._cursor.execute("SELECT permissives FROM permissive WHERE path = ?", (path,)) self._cursor.execute("SELECT permissives FROM permissive WHERE path = ?", (path,))
permissives = self._cursor.fetchone() permissives = self._cursor.fetchone()
if permissives is None: if permissives is None:
return frozenset() return frozenset()
else: else:
return frozenset(self._p_sqlite_decode(permissives[0])) return frozenset(self._sqlite_decode(permissives[0]))

View File

@ -18,10 +18,11 @@
# #
# ____________________________________________________________ # ____________________________________________________________
from tiramisu.plugins.sqlite3.cache import PluginCache from tiramisu.plugins.sqlite3.cache import Cache
from tiramisu.setting import owners
class PluginValues(PluginCache): class Values(Cache):
__slots__ = tuple() __slots__ = tuple()
def __init__(self, config_id): def __init__(self, config_id):
@ -29,80 +30,74 @@ class PluginValues(PluginCache):
""" """
values_table = 'CREATE TABLE IF NOT EXISTS value(path text primary key, value text, owner text)' values_table = 'CREATE TABLE IF NOT EXISTS value(path text primary key, value text, owner text)'
# should init cache too # should init cache too
super(PluginValues, self).__init__(config_id, 'value') super(Values, self).__init__(config_id, 'value')
self._cursor.execute(values_table) self._cursor.execute(values_table)
self._conn.commit() self._conn.commit()
# sqlite # sqlite
def _p_sqlite_select(self, opt): def _sqlite_select(self, path):
path = self._get_opt_path(opt)
self._cursor.execute("SELECT value FROM value WHERE path = ?", (path,)) self._cursor.execute("SELECT value FROM value WHERE path = ?", (path,))
return self._cursor.fetchone() return self._cursor.fetchone()
# value # value
def _p_setvalue(self, opt, value): def setvalue(self, path, value, owner):
"""set value for an option """set value for an option
a specified value must be associated to an owner a specified value must be associated to an owner
""" """
path = self._get_opt_path(opt) self.resetvalue(path)
owner = self.context.cfgimpl_get_settings().getowner()
self._p_resetvalue(opt, path)
self._cursor.execute("INSERT INTO value(path, value, owner) VALUES (?, ?, ?)", self._cursor.execute("INSERT INTO value(path, value, owner) VALUES (?, ?, ?)",
(path, self._p_sqlite_encode(value), str(owner))) (path, self._sqlite_encode(value), str(owner)))
self._conn.commit() self._conn.commit()
def _p_getvalue(self, opt): def getvalue(self, path):
"""get value for an option """get value for an option
return: only value, not the owner return: only value, not the owner
""" """
return self._p_sqlite_decode(self._p_sqlite_select(opt)[0]) return self._sqlite_decode(self._sqlite_select(path)[0])
def _p_hasvalue(self, opt): def hasvalue(self, path):
"""if opt has a value """if opt has a value
return: boolean return: boolean
""" """
return self._p_sqlite_select(opt) is not None return self._sqlite_select(path) is not None
def _p_resetvalue(self, opt, path=None): def resetvalue(self, path):
"""remove value means delete value in storage """remove value means delete value in storage
""" """
if not path:
path = self._get_opt_path(opt)
self._cursor.execute("DELETE FROM value WHERE path = ?", (path,)) self._cursor.execute("DELETE FROM value WHERE path = ?", (path,))
self._conn.commit() self._conn.commit()
def _p_get_modified_values(self): def get_modified_values(self, context):
"""return all values in a dictionary """return all values in a dictionary
example: {option1: (owner, 'value1'), option2: (owner, 'value2')} example: {option1: (owner, 'value1'), option2: (owner, 'value2')}
""" """
self._cursor.execute("SELECT value") self._cursor.execute("SELECT value")
ret = {} ret = {}
for path, value, owner in self._cursor.fetchall(): for path, value, owner in self._cursor.fetchall():
opt = self.context.cfgimpl_get_description().impl_get_opt_by_path(path) opt = context.cfgimpl_get_description().impl_get_opt_by_path(path)
owner = self._get_owner_from_str(owner) owner = getattr(owners, owner)
value = self._p_sqlite_decode(value)
value = self._sqlite_decode(value)
ret[opt] = (owner, value) ret[opt] = (owner, value)
return ret return ret
# owner # owner
def _p_setowner(self, opt, owner): def setowner(self, path, owner):
"""change owner for an option """change owner for an option
""" """
path = self._get_opt_path(opt)
self._cursor.execute("UPDATE value SET owner = ? WHERE path = ?", (str(owner), path)) self._cursor.execute("UPDATE value SET owner = ? WHERE path = ?", (str(owner), path))
self._conn.commit() self._conn.commit()
def _p_getowner(self, opt, default): def getowner(self, path, default):
"""get owner for an option """get owner for an option
return: owner object return: owner object
""" """
path = self._get_opt_path(opt)
self._cursor.execute("SELECT owner FROM value WHERE path = ?", (path,)) self._cursor.execute("SELECT owner FROM value WHERE path = ?", (path,))
owner = self._cursor.fetchone() owner = self._cursor.fetchone()
if owner is None: if owner is None:
return default return default
else: else:
return self._get_owner_from_str(owner[0]) return getattr(owners, owner[0])
def __del__(self): def __del__(self):
self._cursor.close() self._cursor.close()

View File

@ -24,8 +24,6 @@ from time import time
from copy import copy from copy import copy
from tiramisu.error import RequirementError, PropertiesOptionError from tiramisu.error import RequirementError, PropertiesOptionError
from tiramisu.i18n import _ from tiramisu.i18n import _
#from tiramisu.plugins.dictionary.setting import PluginSettings
from tiramisu.plugins.sqlite3.setting import PluginSettings
default_encoding = 'utf-8' default_encoding = 'utf-8'
@ -35,6 +33,7 @@ ro_append = ('frozen', 'disabled', 'validator', 'everything_frozen', 'mandatory'
rw_remove = ('permissive', 'everything_frozen', 'mandatory') rw_remove = ('permissive', 'everything_frozen', 'mandatory')
rw_append = ('frozen', 'disabled', 'validator', 'hidden') rw_append = ('frozen', 'disabled', 'validator', 'hidden')
default_properties = ('expire', 'validator') default_properties = ('expire', 'validator')
default_storage = 'dictionary'
class _const: class _const:
@ -179,15 +178,26 @@ class Property(object):
#____________________________________________________________ #____________________________________________________________
class Settings(PluginSettings): class Settings(object):
"``Config()``'s configuration options" "``Config()``'s configuration options"
__slots__ = ('context', '_owner') __slots__ = ('context', '_owner', '_p_')
def __init__(self, context, config_id): def __init__(self, context, config_id, plugin_name):
# generic owner # generic owner
self._owner = owners.user self._owner = owners.user
self.context = context self.context = context
super(Settings, self).__init__(config_id) import_lib = 'tiramisu.plugins.{0}.setting'.format(plugin_name)
self._p_ = __import__(import_lib, globals(), locals(), ['Settings'],
-1).Settings(config_id)
def _getkey(self, opt):
if self._p_.key_is_path:
if opt is None:
return '_none'
else:
return self._get_opt_path(opt)
else:
return opt
#____________________________________________________________ #____________________________________________________________
# properties methods # properties methods
@ -208,28 +218,28 @@ class Settings(PluginSettings):
raise ValueError(_('opt and all_properties must not be set ' raise ValueError(_('opt and all_properties must not be set '
'together in reset')) 'together in reset'))
if all_properties: if all_properties:
self._p_reset_all_propertives() self._p_.reset_all_propertives()
else: else:
self._p_reset_properties(opt) self._p_.reset_properties(self._getkey(opt))
self.context.cfgimpl_reset_cache() self.context.cfgimpl_reset_cache()
def _getproperties(self, opt=None, is_apply_req=True): def _getproperties(self, opt=None, is_apply_req=True):
if opt is None: if opt is None:
props = self._p_getproperties(opt, default_properties) props = self._p_.getproperties(self._getkey(opt), default_properties)
else: else:
ntime = None ntime = None
if self._p_hascache('property', opt): if self._p_.hascache('property', self._getkey(opt)):
ntime = time() ntime = time()
is_cached, props = self._p_getcache('property', opt, ntime) is_cached, props = self._p_.getcache('property', self._getkey(opt), ntime)
if is_cached: if is_cached:
return props return props
if is_apply_req: if is_apply_req:
self.apply_requires(opt) self.apply_requires(opt)
props = self._p_getproperties(opt, opt._properties) props = self._p_.getproperties(self._getkey(opt), opt._properties)
if 'expire' in self: if 'expire' in self:
if ntime is None: if ntime is None:
ntime = time() ntime = time()
self._p_setcache('property', opt, props, ntime + expires_time) self._p_.setcache('property', self._getkey(opt), props, ntime + expires_time)
return props return props
def append(self, propname): def append(self, propname):
@ -245,12 +255,12 @@ class Settings(PluginSettings):
(never save properties if same has option properties) (never save properties if same has option properties)
""" """
if opt is None: if opt is None:
self._p_setproperties(opt, properties) self._p_.setproperties(self._getkey(opt), properties)
else: else:
if set(opt._properties) == properties: if set(opt._properties) == properties:
self._p_reset_properties(opt) self._p_.reset_properties(self._getkey(opt))
else: else:
self._p_setproperties(opt, properties) self._p_.setproperties(self._getkey(opt), properties)
self.context.cfgimpl_reset_cache() self.context.cfgimpl_reset_cache()
#____________________________________________________________ #____________________________________________________________
@ -260,11 +270,11 @@ class Settings(PluginSettings):
#opt properties #opt properties
properties = copy(self._getproperties(opt_or_descr)) properties = copy(self._getproperties(opt_or_descr))
#remove opt permissive #remove opt permissive
properties -= self._p_getpermissive(opt_or_descr) properties -= self._p_.getpermissive(self._getkey(opt_or_descr))
#remove global permissive if need #remove global permissive if need
self_properties = copy(self._getproperties()) self_properties = copy(self._getproperties())
if force_permissive is True or 'permissive' in self_properties: if force_permissive is True or 'permissive' in self_properties:
properties -= self._p_getpermissive() properties -= self._p_.getpermissive()
#global properties #global properties
if force_properties is not None: if force_properties is not None:
@ -300,7 +310,7 @@ class Settings(PluginSettings):
def set_permissive(self, permissive, opt=None): def set_permissive(self, permissive, opt=None):
if not isinstance(permissive, tuple): if not isinstance(permissive, tuple):
raise TypeError(_('permissive must be a tuple')) raise TypeError(_('permissive must be a tuple'))
self._p_setpermissive(opt, permissive) self._p_.setpermissive(self._getkey(opt), permissive)
#____________________________________________________________ #____________________________________________________________
def setowner(self, owner): def setowner(self, owner):
@ -329,9 +339,9 @@ class Settings(PluginSettings):
def reset_cache(self, only_expired): def reset_cache(self, only_expired):
if only_expired: if only_expired:
self._p_reset_expired_cache('property', time()) self._p_.reset_expired_cache('property', time())
else: else:
self._p_reset_all_cache('property') self._p_.reset_all_cache('property')
def apply_requires(self, opt): def apply_requires(self, opt):
"carries out the jit (just in time requirements between options" "carries out the jit (just in time requirements between options"

View File

@ -25,19 +25,15 @@ from tiramisu.autolib import carry_out_calculation
from tiramisu.i18n import _ from tiramisu.i18n import _
from tiramisu.option import SymLinkOption from tiramisu.option import SymLinkOption
#FIXME
#from tiramisu.plugins.dictionary.value import PluginValues
from tiramisu.plugins.sqlite3.value import PluginValues
class Values(object):
class Values(PluginValues):
"""The `Config`'s root is indeed in charge of the `Option()`'s values, """The `Config`'s root is indeed in charge of the `Option()`'s values,
but the values are physicaly located here, in `Values`, wich is also but the values are physicaly located here, in `Values`, wich is also
responsible of a caching utility. responsible of a caching utility.
""" """
__slots__ = ('context',) __slots__ = ('context', '_p_')
def __init__(self, context, config_id): def __init__(self, context, config_id, plugin_name):
""" """
Initializes the values's dict. Initializes the values's dict.
@ -46,7 +42,15 @@ class Values(PluginValues):
""" """
self.context = context self.context = context
super(Values, self).__init__(config_id) import_lib = 'tiramisu.plugins.{0}.value'.format(plugin_name)
self._p_ = __import__(import_lib, globals(), locals(), ['Values'],
-1).Values(config_id)
def _getkey(self, opt):
if self._p_.key_is_path:
return self._get_opt_path(opt)
else:
return opt
def _getdefault(self, opt): def _getdefault(self, opt):
meta = self.context.cfgimpl_get_meta() meta = self.context.cfgimpl_get_meta()
@ -61,30 +65,32 @@ class Values(PluginValues):
def _getvalue(self, opt, validate=True): def _getvalue(self, opt, validate=True):
"return value or default value if not set" "return value or default value if not set"
if not self._p_hasvalue(opt): key = self._getkey(opt)
if not self._p_.hasvalue(key):
#if no value #if no value
value = self._getdefault(opt) value = self._getdefault(opt)
if opt.impl_is_multi(): if opt.impl_is_multi():
value = Multi(value, self.context, opt, validate) value = Multi(value, self.context, opt, validate)
else: else:
#if value #if value
value = self._p_getvalue(opt) value = self._p_.getvalue(key)
if opt.impl_is_multi() and not isinstance(value, Multi): if opt.impl_is_multi() and not isinstance(value, Multi):
#load value so don't need to validate if is not a Multi #load value so don't need to validate if is not a Multi
value = Multi(value, self.context, opt, validate=False) value = Multi(value, self.context, opt, validate=False)
return value return value
def get_modified_values(self): def get_modified_values(self):
return self._p_get_modified_values() return self._p_.get_modified_values()
def __contains__(self, opt): def __contains__(self, opt):
return self._p_hasvalue('value', opt) return self._p_.hasvalue('value', self._getkey(opt))
def __delitem__(self, opt): def __delitem__(self, opt):
self.reset(opt) self.reset(opt)
def reset(self, opt): def reset(self, opt):
if self._p_hasvalue(opt): key = self._getkey(opt)
if self._p_.hasvalue(key):
setting = self.context.cfgimpl_get_settings() setting = self.context.cfgimpl_get_settings()
opt.impl_validate(opt.impl_getdefault(), self.context, opt.impl_validate(opt.impl_getdefault(), self.context,
'validator' in setting) 'validator' in setting)
@ -92,7 +98,7 @@ class Values(PluginValues):
if opt.impl_is_multi() and opt.impl_get_multitype() == multitypes.master: if opt.impl_is_multi() and opt.impl_get_multitype() == multitypes.master:
for slave in opt.impl_get_master_slaves(): for slave in opt.impl_get_master_slaves():
self.reset(slave) self.reset(slave)
self._p_resetvalue(opt) self._p_.resetvalue(key)
def _isempty(self, opt, value): def _isempty(self, opt, value):
"convenience method to know if an option is empty" "convenience method to know if an option is empty"
@ -118,9 +124,10 @@ class Values(PluginValues):
def getitem(self, opt, validate=True, force_permissive=False, def getitem(self, opt, validate=True, force_permissive=False,
force_properties=None, validate_properties=True): force_properties=None, validate_properties=True):
ntime = None ntime = None
if self._p_hascache('value', opt): key = self._getkey(opt)
if self._p_.hascache('value', self._getkey(opt)):
ntime = time() ntime = time()
is_cached, value = self._p_getcache('value', opt, ntime) is_cached, value = self._p_.getcache('value', key, ntime)
if is_cached: if is_cached:
if opt.impl_is_multi() and not isinstance(value, Multi): if opt.impl_is_multi() and not isinstance(value, Multi):
#load value so don't need to validate if is not a Multi #load value so don't need to validate if is not a Multi
@ -133,7 +140,7 @@ class Values(PluginValues):
force_properties is None: force_properties is None:
if ntime is None: if ntime is None:
ntime = time() ntime = time()
self._p_setcache('value', opt, val, ntime + expires_time) self._p_.setcache('value', key, val, ntime + expires_time)
return val return val
@ -206,12 +213,13 @@ class Values(PluginValues):
value=value, value=value,
force_permissive=force_permissive, force_permissive=force_permissive,
force_properties=force_properties) force_properties=force_properties)
self._p_setvalue(opt, value) owner = self.context.cfgimpl_get_settings().getowner()
self._p_.setvalue(self._getkey(opt), value, owner)
def getowner(self, opt): def getowner(self, opt):
if isinstance(opt, SymLinkOption): if isinstance(opt, SymLinkOption):
opt = opt._opt opt = opt._opt
owner = self._p_getowner(opt, owners.default) owner = self._p_.getowner(self._getkey(opt), owners.default)
meta = self.context.cfgimpl_get_meta() meta = self.context.cfgimpl_get_meta()
if owner is owners.default and meta is not None: if owner is owners.default and meta is not None:
owner = meta.cfgimpl_get_values().getowner(opt) owner = meta.cfgimpl_get_values().getowner(opt)
@ -223,7 +231,7 @@ class Values(PluginValues):
if self.getowner(opt) == owners.default: if self.getowner(opt) == owners.default:
raise ConfigError(_('no value for {0} cannot change owner to {1}' raise ConfigError(_('no value for {0} cannot change owner to {1}'
'').format(opt._name, owner)) '').format(opt._name, owner))
self._p_setowner(opt, owner) self._p_.setowner(self._getkey(opt), owner)
def is_default_owner(self, opt): def is_default_owner(self, opt):
""" """
@ -235,16 +243,13 @@ class Values(PluginValues):
def reset_cache(self, only_expired): def reset_cache(self, only_expired):
if only_expired: if only_expired:
self._p_reset_expired_cache('value', time()) self._p_.reset_expired_cache('value', time())
else: else:
self._p_reset_all_cache('value') self._p_.reset_all_cache('value')
def _get_opt_path(self, opt): def _get_opt_path(self, opt):
return self.context.cfgimpl_get_description().impl_get_path_by_opt(opt) return self.context.cfgimpl_get_description().impl_get_path_by_opt(opt)
def _get_owner_from_str(self, owner):
return getattr(owners, owner)
# ____________________________________________________________ # ____________________________________________________________
# multi types # multi types