we can pickle object
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
import re
|
||||
from copy import copy, deepcopy
|
||||
from copy import copy
|
||||
from types import FunctionType
|
||||
import warnings
|
||||
|
||||
@ -276,16 +276,15 @@ class BaseOption(Base):
|
||||
# remove variable if save variable converted
|
||||
# in _state_xxxx variable
|
||||
if '_state' + slot not in slots:
|
||||
if slot.startswith('_state'):
|
||||
# should exists
|
||||
states[slot] = getattr(self, slot)
|
||||
# remove _state_xxx variable
|
||||
self.__delattr__(slot)
|
||||
else:
|
||||
try:
|
||||
try:
|
||||
if slot.startswith('_state'):
|
||||
states[slot] = getattr(self, slot)
|
||||
except AttributeError:
|
||||
pass
|
||||
# remove _state_xxx variable
|
||||
self.__delattr__(slot)
|
||||
else:
|
||||
states[slot] = getattr(self, slot)
|
||||
except AttributeError:
|
||||
pass
|
||||
if not stated:
|
||||
del(states['_stated'])
|
||||
return states
|
||||
@ -330,7 +329,8 @@ class BaseOption(Base):
|
||||
propertie or "read_only" property)
|
||||
"""
|
||||
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
|
||||
# never change _name
|
||||
if name == '_name':
|
||||
@ -669,14 +669,20 @@ class Option(OnlyOption):
|
||||
def _impl_convert_callbacks(self, descr, load=False):
|
||||
if not load and self._callback is None:
|
||||
self._state_callback = None
|
||||
self._state_callback_params = None
|
||||
elif load and self._state_callback is None:
|
||||
self._callback = None
|
||||
self._callback_params = None
|
||||
del(self._state_callback)
|
||||
del(self._state_callback_params)
|
||||
else:
|
||||
if load:
|
||||
callback, callback_params = self._state_callback
|
||||
callback = self._state_callback
|
||||
callback_params = self._state_callback_params
|
||||
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:
|
||||
cllbck_prms = {}
|
||||
for key, values in callback_params.items():
|
||||
@ -696,9 +702,12 @@ class Option(OnlyOption):
|
||||
|
||||
if load:
|
||||
del(self._state_callback)
|
||||
self._callback = (callback, cllbck_prms)
|
||||
del(self._state_callback_params)
|
||||
self._callback = callback
|
||||
self._callback_params = cllbck_prms
|
||||
else:
|
||||
self._state_callback = (callback, cllbck_prms)
|
||||
self._state_callback = callback
|
||||
self._state_callback_params = cllbck_prms
|
||||
|
||||
# serialize/unserialize
|
||||
def _impl_convert_consistencies(self, descr, load=False):
|
||||
@ -834,7 +843,7 @@ def validate_requires_arg(requires, name):
|
||||
|
||||
class SymLinkOption(OnlyOption):
|
||||
#FIXME : et avec sqlalchemy ca marche vraiment ?
|
||||
__slots__ = ('_opt',)
|
||||
__slots__ = ('_opt', '_state_opt')
|
||||
#not return _opt consistencies
|
||||
#_consistencies = None
|
||||
|
||||
|
@ -188,7 +188,8 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
:param descr: parent :class:`tiramisu.option.OptionDescription`
|
||||
"""
|
||||
if descr is None:
|
||||
self.impl_build_cache()
|
||||
self.impl_build_cache_consistency()
|
||||
self.impl_build_cache_option()
|
||||
descr = self
|
||||
super(OptionDescription, self)._impl_getstate(descr)
|
||||
self._state_group_type = str(self._group_type)
|
||||
@ -219,7 +220,7 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
if descr is None:
|
||||
self._cache_paths = None
|
||||
self._cache_consistencies = None
|
||||
self.impl_build_cache(force_no_consistencies=True)
|
||||
self.impl_build_cache_option()
|
||||
descr = self
|
||||
self._group_type = getattr(groups, self._state_group_type)
|
||||
del(self._state_group_type)
|
||||
|
@ -30,9 +30,9 @@ class Base(object):
|
||||
'_state_readonly', '_state_requires', '_stated',
|
||||
'_multi', '_validator', '_validator_params', '_default',
|
||||
'_default_multi', '_state_callback', '_callback',
|
||||
'_callback_params', '_multitype', '_consistencies',
|
||||
'_warnings_only', '_master_slaves', '_state_consistencies',
|
||||
'_extra', '__weakref__')
|
||||
'_state_callback_params', '_callback_params', '_multitype',
|
||||
'_consistencies', '_warnings_only', '_master_slaves',
|
||||
'_state_consistencies', '_extra', '__weakref__')
|
||||
|
||||
def __init__(self):
|
||||
try:
|
||||
@ -68,7 +68,7 @@ class Base(object):
|
||||
|
||||
class OptionDescription(Base):
|
||||
__slots__ = ('_children', '_cache_paths', '_cache_consistencies',
|
||||
'_group_type', '_is_build_cache')
|
||||
'_group_type', '_is_build_cache', '_state_group_type')
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
@ -158,6 +158,10 @@ class OptionDescription(Base):
|
||||
if name == '_name':
|
||||
return object.__getattribute__(self, name)
|
||||
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)]
|
||||
except ValueError:
|
||||
raise AttributeError(_('unknown Option {0} '
|
||||
|
Reference in New Issue
Block a user