[devtools] fix get_bounds
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 06 Jan 2016 11:47:08 +0100
changeset 11080 245f440b814a
parent 11079 eba98431f705
child 11081 70733b2dfd2a
[devtools] fix get_bounds Say an attribute has two IntervalBoundConstraints, one with minvalue=0 and the other with maxvalue=10 (not literally, or that could be a single constraint, but e.g. with references to other attributes). We don't want to override the minvalue of the former with None just because the latter happens last in the constraints list. This doesn't fix the case where two constraints both have a min or a max value. Meh.
devtools/fill.py
--- a/devtools/fill.py	Wed Jan 06 15:27:59 2016 +0100
+++ b/devtools/fill.py	Wed Jan 06 11:47:08 2016 +0100
@@ -217,8 +217,10 @@
         minvalue = maxvalue = None
         for cst in self.eschema.rdef(attrname).constraints:
             if isinstance(cst, IntervalBoundConstraint):
-                minvalue = self._actual_boundary(entity, attrname, cst.minvalue)
-                maxvalue = self._actual_boundary(entity, attrname, cst.maxvalue)
+                if cst.minvalue is not None:
+                    minvalue = self._actual_boundary(entity, attrname, cst.minvalue)
+                if cst.maxvalue is not None:
+                    maxvalue = self._actual_boundary(entity, attrname, cst.maxvalue)
             elif isinstance(cst, BoundaryConstraint):
                 if cst.operator[0] == '<':
                     maxvalue = self._actual_boundary(entity, attrname, cst.boundary)