we can pickle object

This commit is contained in:
2014-04-14 22:53:40 +02:00
parent a1753afb8c
commit 9bec52273a
4 changed files with 288 additions and 265 deletions

View File

@ -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

View File

@ -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)