Merge branch 'master' into orm
Conflicts: tiramisu/setting.py
This commit is contained in:
@ -24,7 +24,7 @@ from time import time
|
||||
from copy import copy
|
||||
import weakref
|
||||
from tiramisu.error import (RequirementError, PropertiesOptionError,
|
||||
ConstError)
|
||||
ConstError, ConfigError)
|
||||
from tiramisu.i18n import _
|
||||
|
||||
|
||||
@ -328,6 +328,17 @@ class Settings(object):
|
||||
self.context = weakref.ref(context)
|
||||
self._p_ = storage
|
||||
|
||||
def _getcontext(self):
|
||||
"""context could be None, we need to test it
|
||||
context is None only if all reference to `Config` object is deleted
|
||||
(for example we delete a `Config` and we manipulate a reference to
|
||||
old `SubConfig`, `Values`, `Multi` or `Settings`)
|
||||
"""
|
||||
context = self.context()
|
||||
if context is None:
|
||||
raise ConfigError(_('the context does not exist anymore'))
|
||||
return context
|
||||
|
||||
#____________________________________________________________
|
||||
# properties methods
|
||||
def __contains__(self, propname):
|
||||
@ -357,7 +368,7 @@ class Settings(object):
|
||||
if opt is not None and _path is None:
|
||||
_path = self._get_path_by_opt(opt)
|
||||
self._p_.reset_properties(_path)
|
||||
self.context().cfgimpl_reset_cache()
|
||||
self._getcontext().cfgimpl_reset_cache()
|
||||
|
||||
def _getproperties(self, opt=None, path=None, is_apply_req=True):
|
||||
if opt is None:
|
||||
@ -407,14 +418,12 @@ class Settings(object):
|
||||
else:
|
||||
#if opt._calc_properties is not None:
|
||||
# properties -= opt._calc_properties
|
||||
#FIXME a revoir ---------
|
||||
#if set(opt._properties) == properties:
|
||||
# self._p_.reset_properties(path)
|
||||
#else:
|
||||
# self._p_.setproperties(path, properties)
|
||||
self._p_.setproperties(path, properties)
|
||||
#FIXME fin revoir -----
|
||||
self.context().cfgimpl_reset_cache()
|
||||
self._getcontext().cfgimpl_reset_cache()
|
||||
|
||||
#____________________________________________________________
|
||||
def validate_properties(self, opt_or_descr, is_descr, is_write, path,
|
||||
@ -462,7 +471,7 @@ class Settings(object):
|
||||
properties -= frozenset(('mandatory', 'frozen'))
|
||||
else:
|
||||
if 'mandatory' in properties and \
|
||||
not self.context().cfgimpl_get_values()._isempty(
|
||||
not self._getcontext().cfgimpl_get_values()._isempty(
|
||||
opt_or_descr, value):
|
||||
properties.remove('mandatory')
|
||||
if is_write and 'everything_frozen' in self_properties:
|
||||
@ -585,6 +594,8 @@ class Settings(object):
|
||||
|
||||
# filters the callbacks
|
||||
calc_properties = set()
|
||||
<<<<<<< HEAD
|
||||
context = self._getcontext()
|
||||
for require in opt.impl_getrequires():
|
||||
expected = tuple(require.get_expected())
|
||||
inverse = require.inverse
|
||||
@ -596,7 +607,7 @@ class Settings(object):
|
||||
" '{0}' with requirement on: "
|
||||
"'{1}'").format(path, reqpath))
|
||||
try:
|
||||
value = self.context()._getattr(reqpath,
|
||||
value = context._getattr(reqpath,
|
||||
force_permissive=True)
|
||||
except PropertiesOptionError as err:
|
||||
if not require.transitive:
|
||||
@ -625,7 +636,7 @@ class Settings(object):
|
||||
:param opt: `Option`'s object
|
||||
:returns: path
|
||||
"""
|
||||
return self.context().cfgimpl_get_description().impl_get_path_by_opt(opt)
|
||||
return self._getcontext().cfgimpl_get_description().impl_get_path_by_opt(opt)
|
||||
|
||||
def get_modified_properties(self):
|
||||
return self._p_.get_modified_properties()
|
||||
|
Reference in New Issue
Block a user