Merge branch 'master' into orm
authorEmmanuel Garette <egarette@cadoles.com>
Sat, 25 Jan 2014 15:39:32 +0000 (16:39 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Sat, 25 Jan 2014 15:39:32 +0000 (16:39 +0100)
Conflicts:
tiramisu/setting.py

1  2 
test/test_config.py
tiramisu/config.py
tiramisu/setting.py
tiramisu/value.py

Simple merge
Simple merge
@@@ -405,16 -415,13 +416,14 @@@ class Settings(object)
          if opt is None:
              self._p_.setproperties(None, properties)
          else:
 -            if opt._calc_properties is not None:
 -                properties -= opt._calc_properties
 -            if set(opt._properties) == properties:
 -                self._p_.reset_properties(path)
 -            else:
 -                self._p_.setproperties(path, properties)
 +            #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,
  
          # filters the callbacks
          calc_properties = set()
 -        for requires in opt._requires:
 -            for require in requires:
 -                option, expected, action, inverse, \
 -                    transitive, same_action = require
 -                reqpath = self._get_path_by_opt(option)
 -                if reqpath == path or reqpath.startswith(path + '.'):
 -                    raise RequirementError(_("malformed requirements "
 -                                             "imbrication detected for option:"
 -                                             " '{0}' with requirement on: "
 -                                             "'{1}'").format(path, reqpath))
 -                try:
 -                    value = context._getattr(reqpath, force_permissive=True)
 -                except PropertiesOptionError as err:
 -                    if not transitive:
 -                        continue
 -                    properties = err.proptype
 -                    if same_action and action not in properties:
 -                        raise RequirementError(_("option '{0}' has "
 -                                                 "requirement's property "
 -                                                 "error: "
 -                                                 "{1} {2}").format(opt._name,
 -                                                                   reqpath,
 -                                                                   properties))
 -                    # transitive action, force expected
 -                    value = expected[0]
 -                    inverse = False
 -                if (not inverse and
 -                        value in expected or
 -                        inverse and value not in expected):
 -                    calc_properties.add(action)
 -                    # the calculation cannot be carried out
 -                    break
++<<<<<<< HEAD
+         context = self._getcontext()
-                 value = self.context()._getattr(reqpath,
 +        for require in opt.impl_getrequires():
 +            expected = tuple(require.get_expected())
 +            inverse = require.inverse
 +            option = require.option
 +            reqpath = self._get_path_by_opt(option)
 +            if reqpath == path or reqpath.startswith(path + '.'):
 +                raise RequirementError(_("malformed requirements "
 +                                         "imbrication detected for option:"
 +                                         " '{0}' with requirement on: "
 +                                         "'{1}'").format(path, reqpath))
 +            try:
++                value = context._getattr(reqpath,
 +                                                force_permissive=True)
 +            except PropertiesOptionError as err:
 +                if not require.transitive:
 +                    continue
 +                properties = err.proptype
 +                if require.same_action and require.action not in properties:
 +                    raise RequirementError(_("option '{0}' has "
 +                                             "requirement's property "
 +                                             "error: "
 +                                             "{1} {2}").format(opt.impl_getname(),
 +                                                               reqpath,
 +                                                               properties))
 +                # transitive action, force expected
 +                value = expected[0]
 +                inverse = False
 +            if not inverse and value in expected or \
 +                    inverse and value not in expected:
 +                calc_properties.add(require.action)
 +                # the calculation cannot be carried out
 +                #break
          return calc_properties
  
      def _get_path_by_opt(self, opt):
@@@ -134,10 -145,10 +145,10 @@@ class Values(object)
          :type index: int
          :returns: a calculated value
          """
 -        callback, callback_params = opt._callback
 +        callback, callback_params = opt.impl_get_callback()
          if callback_params is None:
              callback_params = {}
-         return carry_out_calculation(opt, config=self.context(),
+         return carry_out_calculation(opt, config=self._getcontext(),
                                       callback=callback,
                                       callback_params=callback_params,
                                       index=index, max_len=max_len)
@@@ -467,9 -494,9 +494,9 @@@ class Multi(list)
          if not force:
              if self.opt.impl_get_multitype() == multitypes.slave:
                  raise SlaveError(_("cannot append a value on a multi option {0}"
 -                                   " which is a slave").format(self.opt._name))
 +                                   " which is a slave").format(self.opt.impl_getname()))
              elif self.opt.impl_get_multitype() == multitypes.master:
-                 values = self.context().cfgimpl_get_values()
+                 values = context.cfgimpl_get_values()
                  if value is undefined and self.opt.impl_has_callback():
                      value = values._getcallback_value(self.opt)
                      #Force None il return a list
          if self.opt.impl_get_multitype() in [multitypes.slave,
                                               multitypes.master]:
              raise SlaveError(_("cannot reverse multi option {0} if master or "
 -                               "slave").format(self.opt._name))
 +                               "slave").format(self.opt.impl_getname()))
          super(Multi, self).reverse()
-         self.context().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
+         self._getcontext().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
  
      def insert(self, index, obj):
          if self.opt.impl_get_multitype() in [multitypes.slave,
                                               multitypes.master]:
              raise SlaveError(_("cannot insert multi option {0} if master or "
 -                               "slave").format(self.opt._name))
 +                               "slave").format(self.opt.impl_getname()))
          super(Multi, self).insert(index, obj)
-         self.context().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
+         self._getcontext().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
  
      def extend(self, iterable):
          if self.opt.impl_get_multitype() in [multitypes.slave,
                                               multitypes.master]:
              raise SlaveError(_("cannot extend multi option {0} if master or "
 -                               "slave").format(self.opt._name))
 +                               "slave").format(self.opt.impl_getname()))
          super(Multi, self).extend(iterable)
-         self.context().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
+         self._getcontext().cfgimpl_get_values()._setvalue(self.opt, self.path, self)
  
      def _validate(self, value, force_index):
          if value is not None:
          if not force:
              if self.opt.impl_get_multitype() == multitypes.slave:
                  raise SlaveError(_("cannot pop a value on a multi option {0}"
 -                                   " which is a slave").format(self.opt._name))
 +                                   " which is a slave").format(self.opt.impl_getname()))
              elif self.opt.impl_get_multitype() == multitypes.master:
                  for slave in self.opt.impl_get_master_slaves():
-                     values = self.context().cfgimpl_get_values()
+                     values = context.cfgimpl_get_values()
                      if not values.is_default_owner(slave):
                          #get multi without valid properties
                          values.getitem(slave,