diff -r 6fa712e9dfa5 -r 0af44a38fe41 devtools/fill.py --- a/devtools/fill.py Mon Jan 24 19:09:42 2011 +0100 +++ b/devtools/fill.py Tue Feb 01 11:52:10 2011 +0100 @@ -27,7 +27,7 @@ from logilab.common import attrdict from yams.constraints import (SizeConstraint, StaticVocabularyConstraint, - IntervalBoundConstraint, BoundConstraint, + IntervalBoundConstraint, BoundaryConstraint, Attribute, actual_value) from rql.utils import decompose_b26 as base_decompose_b26 @@ -190,10 +190,12 @@ minvalue = maxvalue - (index * step) # i.e. randint(-index, 0) return choice(list(custom_range(minvalue, maxvalue, step))) - def _actual_boundary(self, entity, boundary): + def _actual_boundary(self, entity, attrname, boundary): if isinstance(boundary, Attribute): # ensure we've a value for this attribute - self.generate_attribute_value(entity, boundary.attr) + entity[attrname] = None # infinite loop safety belt + if not boundary.attr in entity: + self.generate_attribute_value(entity, boundary.attr) boundary = actual_value(boundary, entity) return boundary @@ -201,13 +203,13 @@ minvalue = maxvalue = None for cst in self.eschema.rdef(attrname).constraints: if isinstance(cst, IntervalBoundConstraint): - minvalue = self._actual_boundary(entity, cst.minvalue) - maxvalue = self._actual_boundary(entity, cst.maxvalue) - elif isinstance(cst, BoundConstraint): + minvalue = self._actual_boundary(entity, attrname, cst.minvalue) + maxvalue = self._actual_boundary(entity, attrname, cst.maxvalue) + elif isinstance(cst, BoundaryConstraint): if cst.operator[0] == '<': - maxvalue = self._actual_boundary(entity, cst.boundary) + maxvalue = self._actual_boundary(entity, attrname, cst.boundary) else: - minvalue = self._actual_boundary(entity, cst.boundary) + minvalue = self._actual_boundary(entity, attrname, cst.boundary) return minvalue, maxvalue def get_choice(self, entity, attrname):