From 62b583df02962c721cbf0a260c12d5647f3bc492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 29 Sep 2008 11:19:50 +0200 Subject: [PATCH] Fix search for XML-RPC as it handles tuple as list --- trytond/osv/orm.py | 58 ++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 02ac1dde67..c08f0b6e4b 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -13,6 +13,23 @@ import copy from trytond.sql_db import table_handler from decimal import Decimal +OPERATORS = ( + 'child_of', + 'not child_of', + '=', + '!=', + 'like', + 'not like', + 'ilike', + 'not ilike', + 'in', + 'not in', + '<=', + '>=', + '<', + '>', + ) + def intersect(i, j): return [x for x in j if x in i] @@ -2280,10 +2297,13 @@ class ORM(object): tuple_args = [] list_args = [] for arg in args: - if isinstance(arg, list): + #add test for xmlrpc that doesn't handle tuple + if isinstance(arg, tuple) \ + or (isinstance(arg, list) and len(arg) > 2 \ + and arg[1] in OPERATORS): + tuple_args.append(tuple(arg)) + elif isinstance(arg, list): list_args.append(arg) - elif isinstance(arg, tuple): - tuple_args.append(arg) qu1, qu2 = self.__where_calc(cursor, user, tuple_args, tables, tables_args, context=context) @@ -2313,21 +2333,7 @@ class ORM(object): i = 0 joins = [] while i < len(args): - if args[i][1] not in ( - 'child_of', - 'not child_of', - '=', - '!=', - 'like', - 'not like', - 'ilike', - 'not ilike', - 'in', - 'not in', - '<=', - '>=', - '<', - '>'): + if args[i][1] not in OPERATORS: raise Exception('ValidateError', 'Argument "%s" not supported' \ % args[i][1]) @@ -2821,21 +2827,7 @@ class ORM(object): ('field name', 'operator', value) field name: is the name of a field of the object or a relational field by using '.' as separator. - operator can be: - child_of (all the childs of a relation field) - not child_of - = - != - like - not like - ilike (case insensitive) - not ilike - in - not in - <= - >= - < - > + operator must be in OPERATORS :param offset: an integer to specify the offset in the result :param limit: an integer to limit the number of ids return :param order: a list of tupe that are construct like this: