def filter_from_url_arg(model_cls, query, arg, query_operator=and_,<EOL>arg_types=None):
fields = arg.split('<STR_LIT:U+002C>')<EOL>mapper = class_mapper(model_cls)<EOL>if not arg_types:<EOL><INDENT>arg_types = {}<EOL><DEDENT>exprs = []<EOL>joins = set()<EOL>for expr in fields:<EOL><INDENT>if expr == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>e_mapper = mapper<EOL>e_model_cls = model_cls<EOL>operator = None<EOL>method = None<EOL>for op in operator_order:<EOL><INDENT>if op in expr:<EOL><INDENT>operator = op<EOL>method = operator_to_method[op]<EOL>break<EOL><DEDENT><DEDENT>if operator is None:<EOL><INDENT>raise Exception('<STR_LIT>'.format(expr))<EOL><DEDENT>(column_names, value) = expr.split(operator)<EOL>column_names = column_names.split('<STR_LIT>')<EOL>value = value.strip()<EOL>for column_name in column_names:<EOL><INDENT>if column_name in arg_types:<EOL><INDENT>typed_value = arg_types[column_name](value)<EOL><DEDENT>else:<EOL><INDENT>typed_value = value<EOL><DEDENT>if column_name in e_mapper.relationships:<EOL><INDENT>joins.add(column_name)<EOL>e_model_cls = e_mapper.attrs[column_name].mapper.class_<EOL>e_mapper = class_mapper(e_model_cls)<EOL><DEDENT><DEDENT>if hasattr(e_model_cls, column_name):<EOL><INDENT>column = getattr(e_model_cls, column_name)<EOL>exprs.append(getattr(column, method)(typed_value))<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>'.format(column_name, e_model_cls))<EOL><DEDENT><DEDENT>return query.join(*joins).filter(query_operator(*exprs))<EOL>
Parse filter URL argument ``arg`` and apply to ``query``

Example: 'column1<=value,column2==value' -> query.filter(Model.column1 <= value, Model.column2 == value)