Test the id and the fullid in condition

And use obj.to_dict instead of dict(obj.iter_fields())
This commit is contained in:
Florent 2014-04-09 10:30:19 +02:00
commit 7555938470

View file

@ -92,12 +92,19 @@ class ResultsCondition(IResultsCondition):
self.condition_str = condition_str self.condition_str = condition_str
def is_valid(self, obj): def is_valid(self, obj):
d = dict(obj.iter_fields()) d = obj.to_dict()
# We evaluate all member of a list at each iteration. # We evaluate all member of a list at each iteration.
for _or in self.condition: for _or in self.condition:
myeval = True myeval = True
for condition in _or: for condition in _or:
if condition.left in d: if condition.left in d:
# in the case of id, test id@backend and id
if condition.left == 'id':
tocompare = condition.right
evalfullid = functions[condition.op](tocompare, d['id'])
evalid = functions[condition.op](tocompare, obj.id)
myeval = evalfullid or evalid
else:
# We have to change the type of v, always gived as string by application # We have to change the type of v, always gived as string by application
typed = type(d[condition.left]) typed = type(d[condition.left])
try: try: