require works well in sqlalchemy storage
[tiramisu.git] / tiramisu / setting.py
index b491d47..4d7da51 100644 (file)
@@ -385,7 +385,7 @@ class Settings(object):
                 if is_cached:
                     return props
             #FIXME
-            props = self._p_.getproperties(path, opt.impl_getproperties())
+            props = self._p_.getproperties(path, opt._properties)
             if is_apply_req:
                 props |= self.apply_requires(opt, path)
             if 'cache' in self:
@@ -589,44 +589,45 @@ class Settings(object):
         :param path: the option's path in the config
         :type path: str
         """
-        if opt.impl_getrequires() is None:
+        if opt._requires is None:
             return frozenset()
 
         # filters the callbacks
         calc_properties = set()
         context = self._getcontext()
-        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
+        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
         return calc_properties
 
     def _get_path_by_opt(self, opt):