we can pickle object
This commit is contained in:
parent
a1753afb8c
commit
9bec52273a
|
@ -66,8 +66,11 @@ def _diff_opt(opt1, opt2):
|
||||||
for index, _opt in enumerate(val1[1]):
|
for index, _opt in enumerate(val1[1]):
|
||||||
assert _opt._name == val2[1][index]._name
|
assert _opt._name == val2[1][index]._name
|
||||||
elif attr == '_requires':
|
elif attr == '_requires':
|
||||||
assert val1[0][0][0]._name == val2[0][0][0]._name
|
if val1 == val2 == []:
|
||||||
assert val1[0][0][1:] == val2[0][0][1:]
|
pass
|
||||||
|
else:
|
||||||
|
assert val1[0][0][0]._name == val2[0][0][0]._name
|
||||||
|
assert val1[0][0][1:] == val2[0][0][1:]
|
||||||
elif attr == '_opt':
|
elif attr == '_opt':
|
||||||
assert val1._name == val2._name
|
assert val1._name == val2._name
|
||||||
elif attr == '_consistencies':
|
elif attr == '_consistencies':
|
||||||
|
@ -78,17 +81,18 @@ def _diff_opt(opt1, opt2):
|
||||||
for idx, opt in enumerate(consistency[1]):
|
for idx, opt in enumerate(consistency[1]):
|
||||||
assert opt._name == val2[index][1][idx]._name
|
assert opt._name == val2[index][1][idx]._name
|
||||||
elif attr == '_callback':
|
elif attr == '_callback':
|
||||||
assert val1[0] == val2[0]
|
assert val1 == val2
|
||||||
if val1[1] is not None:
|
elif attr == '_callback_params':
|
||||||
for key, values in val1[1].items():
|
if val1 is not None:
|
||||||
|
for key, values in val1.items():
|
||||||
for idx, value in enumerate(values):
|
for idx, value in enumerate(values):
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
assert val1[1][key][idx][0]._name == val2[1][key][idx][0]._name
|
assert val1[key][idx][0]._name == val2[key][idx][0]._name
|
||||||
assert val1[1][key][idx][1] == val2[1][key][idx][1]
|
assert val1[key][idx][1] == val2[key][idx][1]
|
||||||
else:
|
else:
|
||||||
assert val1[1][key][idx] == val2[1][key][idx]
|
assert val1[key][idx] == val2[key][idx]
|
||||||
else:
|
else:
|
||||||
assert val1[1] == val2[1]
|
assert val1 == val2
|
||||||
else:
|
else:
|
||||||
assert val1 == val2
|
assert val1 == val2
|
||||||
|
|
||||||
|
@ -128,241 +132,246 @@ def _diff_conf(cfg1, cfg2):
|
||||||
assert cfg1.cfgimpl_get_settings().get_modified_permissives() == cfg2.cfgimpl_get_settings().get_modified_permissives()
|
assert cfg1.cfgimpl_get_settings().get_modified_permissives() == cfg2.cfgimpl_get_settings().get_modified_permissives()
|
||||||
elif attr == '_impl_descr':
|
elif attr == '_impl_descr':
|
||||||
_diff_opt(cfg1.cfgimpl_get_description(), cfg2.cfgimpl_get_description())
|
_diff_opt(cfg1.cfgimpl_get_description(), cfg2.cfgimpl_get_description())
|
||||||
|
elif attr == '_impl_children':
|
||||||
|
for index, _opt in enumerate(val1):
|
||||||
|
_diff_conf(_opt, val2[index])
|
||||||
else:
|
else:
|
||||||
assert val1 == val2
|
assert val1 == val2
|
||||||
|
|
||||||
|
|
||||||
#def test_diff_opt():
|
def test_diff_opt():
|
||||||
# b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
# s = SymLinkOption('s', u)
|
s = SymLinkOption('s', u)
|
||||||
# o = OptionDescription('o', '', [b, u, s])
|
o = OptionDescription('o', '', [b, u, s])
|
||||||
# o1 = OptionDescription('o1', '', [o])
|
o1 = OptionDescription('o1', '', [o])
|
||||||
#
|
|
||||||
# a = dumps(o1)
|
a = dumps(o1)
|
||||||
# q = loads(a)
|
q = loads(a)
|
||||||
# _diff_opt(o1, q)
|
_diff_opt(o1, q)
|
||||||
# _diff_opt(o1.o, q.o)
|
_diff_opt(o1.o, q.o)
|
||||||
# _diff_opt(o1.o.b, q.o.b)
|
_diff_opt(o1.o.b, q.o.b)
|
||||||
# _diff_opt(o1.o.u, q.o.u)
|
_diff_opt(o1.o.u, q.o.u)
|
||||||
# _diff_opt(o1.o.s, q.o.s)
|
_diff_opt(o1.o.s, q.o.s)
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_only_optiondescription():
|
def test_only_optiondescription():
|
||||||
# b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
# raises(SystemError, "a = dumps(b)")
|
raises(SystemError, "a = dumps(b)")
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_diff_opt_cache():
|
def test_diff_opt_cache():
|
||||||
# b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
# u.impl_add_consistency('not_equal', b)
|
u.impl_add_consistency('not_equal', b)
|
||||||
# s = SymLinkOption('s', u)
|
s = SymLinkOption('s', u)
|
||||||
# o = OptionDescription('o', '', [b, u, s])
|
o = OptionDescription('o', '', [b, u, s])
|
||||||
# o1 = OptionDescription('o1', '', [o])
|
o1 = OptionDescription('o1', '', [o])
|
||||||
# o1.impl_build_cache()
|
o1.impl_build_cache_consistency()
|
||||||
#
|
o1.impl_build_cache_option()
|
||||||
# a = dumps(o1)
|
|
||||||
# q = loads(a)
|
a = dumps(o1)
|
||||||
# _diff_opt(o1, q)
|
q = loads(a)
|
||||||
# _diff_opt(o1.o, q.o)
|
_diff_opt(o1, q)
|
||||||
# _diff_opt(o1.o.b, q.o.b)
|
_diff_opt(o1.o, q.o)
|
||||||
# _diff_opt(o1.o.u, q.o.u)
|
_diff_opt(o1.o.b, q.o.b)
|
||||||
# _diff_opt(o1.o.s, q.o.s)
|
_diff_opt(o1.o.u, q.o.u)
|
||||||
#
|
_diff_opt(o1.o.s, q.o.s)
|
||||||
#
|
|
||||||
#def test_diff_opt_callback():
|
|
||||||
# b = BoolOption('b', '', callback=return_value)
|
def test_diff_opt_callback():
|
||||||
# b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
|
b = BoolOption('b', '', callback=return_value)
|
||||||
# b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
|
b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
|
||||||
# o = OptionDescription('o', '', [b, b2, b3])
|
b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
|
||||||
# o1 = OptionDescription('o1', '', [o])
|
o = OptionDescription('o', '', [b, b2, b3])
|
||||||
# o1.impl_build_cache()
|
o1 = OptionDescription('o1', '', [o])
|
||||||
#
|
o1.impl_build_cache_consistency()
|
||||||
# a = dumps(o1)
|
o1.impl_build_cache_option()
|
||||||
# q = loads(a)
|
|
||||||
# _diff_opt(o1, q)
|
a = dumps(o1)
|
||||||
# _diff_opt(o1.o, q.o)
|
q = loads(a)
|
||||||
# _diff_opt(o1.o.b, q.o.b)
|
_diff_opt(o1, q)
|
||||||
# _diff_opt(o1.o.b2, q.o.b2)
|
_diff_opt(o1.o, q.o)
|
||||||
# _diff_opt(o1.o.b3, q.o.b3)
|
_diff_opt(o1.o.b, q.o.b)
|
||||||
#
|
_diff_opt(o1.o.b2, q.o.b2)
|
||||||
#
|
_diff_opt(o1.o.b3, q.o.b3)
|
||||||
#def test_no_state_attr():
|
|
||||||
# # all _state_xxx attributes should be deleted
|
|
||||||
# b = BoolOption('b', '')
|
def test_no_state_attr():
|
||||||
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
# all _state_xxx attributes should be deleted
|
||||||
# s = SymLinkOption('s', u)
|
b = BoolOption('b', '')
|
||||||
# o = OptionDescription('o', '', [b, u, s])
|
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
# o1 = OptionDescription('o1', '', [o])
|
s = SymLinkOption('s', u)
|
||||||
#
|
o = OptionDescription('o', '', [b, u, s])
|
||||||
# a = dumps(o1)
|
o1 = OptionDescription('o1', '', [o])
|
||||||
# q = loads(a)
|
|
||||||
# _no_state(q)
|
a = dumps(o1)
|
||||||
# _no_state(q.o)
|
q = loads(a)
|
||||||
# _no_state(q.o.b)
|
_no_state(q)
|
||||||
# _no_state(q.o.u)
|
_no_state(q.o)
|
||||||
# _no_state(q.o.s)
|
_no_state(q.o.b)
|
||||||
#
|
_no_state(q.o.u)
|
||||||
#
|
_no_state(q.o.s)
|
||||||
#def test_state_config():
|
|
||||||
# val1 = BoolOption('val1', "")
|
|
||||||
# maconfig = OptionDescription('rootconfig', '', [val1])
|
def test_state_config():
|
||||||
# try:
|
val1 = BoolOption('val1', "")
|
||||||
# cfg = Config(maconfig, persistent=True, session_id='29090931')
|
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
# except ValueError:
|
try:
|
||||||
# cfg = Config(maconfig, session_id='29090931')
|
cfg = Config(maconfig, persistent=True, session_id='29090931')
|
||||||
# cfg._impl_test = True
|
except ValueError:
|
||||||
# a = dumps(cfg)
|
cfg = Config(maconfig, session_id='29090931')
|
||||||
# q = loads(a)
|
cfg._impl_test = True
|
||||||
# _diff_conf(cfg, q)
|
a = dumps(cfg)
|
||||||
# try:
|
q = loads(a)
|
||||||
# delete_session('29090931')
|
_diff_conf(cfg, q)
|
||||||
# except ConfigError:
|
try:
|
||||||
# pass
|
delete_session('config', '29090931')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_properties():
|
|
||||||
# val1 = BoolOption('val1', "")
|
|
||||||
# maconfig = OptionDescription('rootconfig', '', [val1])
|
def test_state_properties():
|
||||||
# try:
|
val1 = BoolOption('val1', "")
|
||||||
# cfg = Config(maconfig, persistent=True, session_id='29090932')
|
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
# except ValueError:
|
try:
|
||||||
# cfg = Config(maconfig, session_id='29090932')
|
cfg = Config(maconfig, persistent=True, session_id='29090932')
|
||||||
# cfg._impl_test = True
|
except ValueError:
|
||||||
# cfg.read_write()
|
cfg = Config(maconfig, session_id='29090932')
|
||||||
# cfg.cfgimpl_get_settings()[val1].append('test')
|
cfg._impl_test = True
|
||||||
# a = dumps(cfg)
|
cfg.read_write()
|
||||||
# q = loads(a)
|
cfg.cfgimpl_get_settings()[val1].append('test')
|
||||||
# _diff_conf(cfg, q)
|
a = dumps(cfg)
|
||||||
# try:
|
q = loads(a)
|
||||||
# delete_session('29090932')
|
_diff_conf(cfg, q)
|
||||||
# except ConfigError:
|
try:
|
||||||
# pass
|
delete_session('config', '29090932')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_values():
|
|
||||||
# val1 = BoolOption('val1', "")
|
|
||||||
# maconfig = OptionDescription('rootconfig', '', [val1])
|
def test_state_values():
|
||||||
# try:
|
val1 = BoolOption('val1', "")
|
||||||
# cfg = Config(maconfig, persistent=True, session_id='29090933')
|
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
# except ValueError:
|
try:
|
||||||
# cfg = Config(maconfig, session_id='29090933')
|
cfg = Config(maconfig, persistent=True, session_id='29090933')
|
||||||
# cfg._impl_test = True
|
except ValueError:
|
||||||
# cfg.val1 = True
|
cfg = Config(maconfig, session_id='29090933')
|
||||||
# a = dumps(cfg)
|
cfg._impl_test = True
|
||||||
# q = loads(a)
|
cfg.val1 = True
|
||||||
# _diff_conf(cfg, q)
|
a = dumps(cfg)
|
||||||
# q.val1 = False
|
q = loads(a)
|
||||||
# #assert cfg.val1 is True
|
_diff_conf(cfg, q)
|
||||||
# assert q.val1 is False
|
q.val1 = False
|
||||||
# try:
|
assert cfg.val1 is True
|
||||||
# delete_session('29090933')
|
assert q.val1 is False
|
||||||
# except ConfigError:
|
try:
|
||||||
# pass
|
delete_session('config', '29090933')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_values_owner():
|
|
||||||
# val1 = BoolOption('val1', "")
|
|
||||||
# maconfig = OptionDescription('rootconfig', '', [val1])
|
def test_state_values_owner():
|
||||||
# try:
|
val1 = BoolOption('val1', "")
|
||||||
# cfg = Config(maconfig, persistent=True, session_id='29090934')
|
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
# except ValueError:
|
try:
|
||||||
# cfg = Config(maconfig, session_id='29090934')
|
cfg = Config(maconfig, persistent=True, session_id='29090934')
|
||||||
# cfg._impl_test = True
|
except ValueError:
|
||||||
# owners.addowner('newowner')
|
cfg = Config(maconfig, session_id='29090934')
|
||||||
# cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
cfg._impl_test = True
|
||||||
# cfg.val1 = True
|
owners.addowner('newowner')
|
||||||
# a = dumps(cfg)
|
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||||
# q = loads(a)
|
cfg.val1 = True
|
||||||
# _diff_conf(cfg, q)
|
a = dumps(cfg)
|
||||||
# q.val1 = False
|
q = loads(a)
|
||||||
# nval1 = q.cfgimpl_get_description().val1
|
_diff_conf(cfg, q)
|
||||||
# assert q.getowner(nval1) == owners.newowner
|
q.val1 = False
|
||||||
# try:
|
nval1 = q.cfgimpl_get_description().val1
|
||||||
# delete_session('29090934')
|
assert q.getowner(nval1) == owners.newowner
|
||||||
# except ConfigError:
|
try:
|
||||||
# pass
|
delete_session('config', '29090934')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_metaconfig():
|
|
||||||
# i1 = IntOption('i1', '')
|
|
||||||
# od1 = OptionDescription('od1', '', [i1])
|
def test_state_metaconfig():
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
i1 = IntOption('i1', '')
|
||||||
# conf1 = Config(od2, session_id='29090935')
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
# conf1._impl_test = True
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
# conf2 = Config(od2, session_id='29090936')
|
conf1 = Config(od2, session_id='29090935')
|
||||||
# conf2._impl_test = True
|
conf1._impl_test = True
|
||||||
# meta = MetaConfig([conf1, conf2], session_id='29090937')
|
conf2 = Config(od2, session_id='29090936')
|
||||||
# meta._impl_test = True
|
conf2._impl_test = True
|
||||||
# raises(ConfigError, "dumps(meta)")
|
meta = MetaConfig([conf1, conf2], session_id='29090937')
|
||||||
# try:
|
meta._impl_test = True
|
||||||
# delete_session('29090935')
|
raises(ConfigError, "dumps(meta)")
|
||||||
# delete_session('29090936')
|
try:
|
||||||
# delete_session('29090937')
|
delete_session('config', '29090935')
|
||||||
# except ConfigError:
|
delete_session('config', '29090936')
|
||||||
# pass
|
delete_session('config', '29090937')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_groupconfig():
|
|
||||||
# i1 = IntOption('i1', '')
|
|
||||||
# od1 = OptionDescription('od1', '', [i1])
|
def test_state_groupconfig():
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
i1 = IntOption('i1', '')
|
||||||
# conf1 = Config(od2, session_id='29090935')
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
# conf1._impl_test = True
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
# conf2 = Config(od2, session_id='29090936')
|
conf1 = Config(od2, session_id='29090935')
|
||||||
# conf2._impl_test = True
|
conf1._impl_test = True
|
||||||
# meta = GroupConfig([conf1, conf2], session_id='29090937')
|
conf2 = Config(od2, session_id='29090936')
|
||||||
# meta._impl_test = True
|
conf2._impl_test = True
|
||||||
# a = dumps(meta)
|
meta = GroupConfig([conf1, conf2], session_id='29090937')
|
||||||
# q = loads(a)
|
meta._impl_test = True
|
||||||
# _diff_conf(meta, q)
|
a = dumps(meta)
|
||||||
# try:
|
q = loads(a)
|
||||||
# delete_session('29090935')
|
_diff_conf(meta, q)
|
||||||
# delete_session('29090936')
|
try:
|
||||||
# delete_session('29090937')
|
delete_session('config', '29090935')
|
||||||
# except ConfigError:
|
delete_session('config', '29090936')
|
||||||
# pass
|
delete_session('config', '29090937')
|
||||||
#
|
except ConfigError:
|
||||||
#
|
pass
|
||||||
#def test_state_unkown_setting_owner():
|
|
||||||
# """load an unknow _owner, should create it"""
|
|
||||||
# assert not 'supernewuser' in owners.__dict__
|
def test_state_unkown_setting_owner():
|
||||||
# loads("""ccopy_reg
|
"""load an unknow _owner, should create it"""
|
||||||
#_reconstructor
|
assert not 'supernewuser' in owners.__dict__
|
||||||
#p0
|
loads("""ccopy_reg
|
||||||
#(ctiramisu.setting
|
_reconstructor
|
||||||
#Settings
|
p0
|
||||||
#p1
|
(ctiramisu.setting
|
||||||
#c__builtin__
|
Settings
|
||||||
#object
|
p1
|
||||||
#p2
|
c__builtin__
|
||||||
#Ntp3
|
object
|
||||||
#Rp4
|
p2
|
||||||
#(dp5
|
Ntp3
|
||||||
#S'_owner'
|
Rp4
|
||||||
#p6
|
(dp5
|
||||||
#S'supernewuser'
|
S'_owner'
|
||||||
#p7
|
p6
|
||||||
#sS'_p_'
|
S'supernewuser'
|
||||||
#p8
|
p7
|
||||||
#g0
|
sS'_p_'
|
||||||
#(ctiramisu.storage.dictionary.setting
|
p8
|
||||||
#Settings
|
g0
|
||||||
#p9
|
(ctiramisu.storage.dictionary.setting
|
||||||
#g2
|
Settings
|
||||||
#Ntp10
|
p9
|
||||||
#Rp11
|
g2
|
||||||
#(dp12
|
Ntp10
|
||||||
#S'_cache'
|
Rp11
|
||||||
#p13
|
(dp12
|
||||||
#(dp14
|
S'_cache'
|
||||||
#sS'_permissives'
|
p13
|
||||||
#p15
|
(dp14
|
||||||
#(dp16
|
sS'_permissives'
|
||||||
#sS'_properties'
|
p15
|
||||||
#p17
|
(dp16
|
||||||
#(dp18
|
sS'_properties'
|
||||||
#sbsb.
|
p17
|
||||||
#.""")
|
(dp18
|
||||||
# assert 'supernewuser' in owners.__dict__
|
sbsb.
|
||||||
|
.""")
|
||||||
|
assert 'supernewuser' in owners.__dict__
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
# the whole pypy projet is under MIT licence
|
# the whole pypy projet is under MIT licence
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
import re
|
import re
|
||||||
from copy import copy, deepcopy
|
from copy import copy
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
@ -276,16 +276,15 @@ class BaseOption(Base):
|
||||||
# remove variable if save variable converted
|
# remove variable if save variable converted
|
||||||
# in _state_xxxx variable
|
# in _state_xxxx variable
|
||||||
if '_state' + slot not in slots:
|
if '_state' + slot not in slots:
|
||||||
if slot.startswith('_state'):
|
try:
|
||||||
# should exists
|
if slot.startswith('_state'):
|
||||||
states[slot] = getattr(self, slot)
|
|
||||||
# remove _state_xxx variable
|
|
||||||
self.__delattr__(slot)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
states[slot] = getattr(self, slot)
|
states[slot] = getattr(self, slot)
|
||||||
except AttributeError:
|
# remove _state_xxx variable
|
||||||
pass
|
self.__delattr__(slot)
|
||||||
|
else:
|
||||||
|
states[slot] = getattr(self, slot)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
if not stated:
|
if not stated:
|
||||||
del(states['_stated'])
|
del(states['_stated'])
|
||||||
return states
|
return states
|
||||||
|
@ -330,7 +329,8 @@ class BaseOption(Base):
|
||||||
propertie or "read_only" property)
|
propertie or "read_only" property)
|
||||||
"""
|
"""
|
||||||
if name not in ('_option', '_is_build_cache') \
|
if name not in ('_option', '_is_build_cache') \
|
||||||
and not isinstance(value, tuple):
|
and not isinstance(value, tuple) and \
|
||||||
|
not name.startswith('_state'):
|
||||||
is_readonly = False
|
is_readonly = False
|
||||||
# never change _name
|
# never change _name
|
||||||
if name == '_name':
|
if name == '_name':
|
||||||
|
@ -669,14 +669,20 @@ class Option(OnlyOption):
|
||||||
def _impl_convert_callbacks(self, descr, load=False):
|
def _impl_convert_callbacks(self, descr, load=False):
|
||||||
if not load and self._callback is None:
|
if not load and self._callback is None:
|
||||||
self._state_callback = None
|
self._state_callback = None
|
||||||
|
self._state_callback_params = None
|
||||||
elif load and self._state_callback is None:
|
elif load and self._state_callback is None:
|
||||||
self._callback = None
|
self._callback = None
|
||||||
|
self._callback_params = None
|
||||||
del(self._state_callback)
|
del(self._state_callback)
|
||||||
|
del(self._state_callback_params)
|
||||||
else:
|
else:
|
||||||
if load:
|
if load:
|
||||||
callback, callback_params = self._state_callback
|
callback = self._state_callback
|
||||||
|
callback_params = self._state_callback_params
|
||||||
else:
|
else:
|
||||||
callback, callback_params = self._callback
|
callback = self._callback
|
||||||
|
callback_params = self._callback_params
|
||||||
|
self._state_callback_params = None
|
||||||
if callback_params is not None:
|
if callback_params is not None:
|
||||||
cllbck_prms = {}
|
cllbck_prms = {}
|
||||||
for key, values in callback_params.items():
|
for key, values in callback_params.items():
|
||||||
|
@ -696,9 +702,12 @@ class Option(OnlyOption):
|
||||||
|
|
||||||
if load:
|
if load:
|
||||||
del(self._state_callback)
|
del(self._state_callback)
|
||||||
self._callback = (callback, cllbck_prms)
|
del(self._state_callback_params)
|
||||||
|
self._callback = callback
|
||||||
|
self._callback_params = cllbck_prms
|
||||||
else:
|
else:
|
||||||
self._state_callback = (callback, cllbck_prms)
|
self._state_callback = callback
|
||||||
|
self._state_callback_params = cllbck_prms
|
||||||
|
|
||||||
# serialize/unserialize
|
# serialize/unserialize
|
||||||
def _impl_convert_consistencies(self, descr, load=False):
|
def _impl_convert_consistencies(self, descr, load=False):
|
||||||
|
@ -834,7 +843,7 @@ def validate_requires_arg(requires, name):
|
||||||
|
|
||||||
class SymLinkOption(OnlyOption):
|
class SymLinkOption(OnlyOption):
|
||||||
#FIXME : et avec sqlalchemy ca marche vraiment ?
|
#FIXME : et avec sqlalchemy ca marche vraiment ?
|
||||||
__slots__ = ('_opt',)
|
__slots__ = ('_opt', '_state_opt')
|
||||||
#not return _opt consistencies
|
#not return _opt consistencies
|
||||||
#_consistencies = None
|
#_consistencies = None
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,8 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||||
:param descr: parent :class:`tiramisu.option.OptionDescription`
|
:param descr: parent :class:`tiramisu.option.OptionDescription`
|
||||||
"""
|
"""
|
||||||
if descr is None:
|
if descr is None:
|
||||||
self.impl_build_cache()
|
self.impl_build_cache_consistency()
|
||||||
|
self.impl_build_cache_option()
|
||||||
descr = self
|
descr = self
|
||||||
super(OptionDescription, self)._impl_getstate(descr)
|
super(OptionDescription, self)._impl_getstate(descr)
|
||||||
self._state_group_type = str(self._group_type)
|
self._state_group_type = str(self._group_type)
|
||||||
|
@ -219,7 +220,7 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||||
if descr is None:
|
if descr is None:
|
||||||
self._cache_paths = None
|
self._cache_paths = None
|
||||||
self._cache_consistencies = None
|
self._cache_consistencies = None
|
||||||
self.impl_build_cache(force_no_consistencies=True)
|
self.impl_build_cache_option()
|
||||||
descr = self
|
descr = self
|
||||||
self._group_type = getattr(groups, self._state_group_type)
|
self._group_type = getattr(groups, self._state_group_type)
|
||||||
del(self._state_group_type)
|
del(self._state_group_type)
|
||||||
|
|
|
@ -30,9 +30,9 @@ class Base(object):
|
||||||
'_state_readonly', '_state_requires', '_stated',
|
'_state_readonly', '_state_requires', '_stated',
|
||||||
'_multi', '_validator', '_validator_params', '_default',
|
'_multi', '_validator', '_validator_params', '_default',
|
||||||
'_default_multi', '_state_callback', '_callback',
|
'_default_multi', '_state_callback', '_callback',
|
||||||
'_callback_params', '_multitype', '_consistencies',
|
'_state_callback_params', '_callback_params', '_multitype',
|
||||||
'_warnings_only', '_master_slaves', '_state_consistencies',
|
'_consistencies', '_warnings_only', '_master_slaves',
|
||||||
'_extra', '__weakref__')
|
'_state_consistencies', '_extra', '__weakref__')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -68,7 +68,7 @@ class Base(object):
|
||||||
|
|
||||||
class OptionDescription(Base):
|
class OptionDescription(Base):
|
||||||
__slots__ = ('_children', '_cache_paths', '_cache_consistencies',
|
__slots__ = ('_children', '_cache_paths', '_cache_consistencies',
|
||||||
'_group_type', '_is_build_cache')
|
'_group_type', '_is_build_cache', '_state_group_type')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
@ -158,6 +158,10 @@ class OptionDescription(Base):
|
||||||
if name == '_name':
|
if name == '_name':
|
||||||
return object.__getattribute__(self, name)
|
return object.__getattribute__(self, name)
|
||||||
try:
|
try:
|
||||||
|
if name == '_readonly':
|
||||||
|
raise AttributeError("{0} instance has no attribute "
|
||||||
|
"'_readonly'".format(
|
||||||
|
self.__class__.__name__))
|
||||||
return self._children[1][self._children[0].index(name)]
|
return self._children[1][self._children[0].index(name)]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AttributeError(_('unknown Option {0} '
|
raise AttributeError(_('unknown Option {0} '
|
||||||
|
|
Loading…
Reference in New Issue