def alter_search(self, search):
    field_list_option = self.get_option('field_list')
    if (not field_list_option):
        return
    stmt = ('field_info_list = %s' % field_list_option.replace('\n', ' '))
    try:
        exec(stmt)
    except:
        return
    for field_info in field_info_list:
        field = field_info.get('field')
        op = field_info.get('op')
        if (not op):
            op = '='
        if field:
            value = self.values.get(field)
            to = field_info.get('to')
            if to:
                if to.endswith('()'):
                    stmt = ('value = value.%s' % to)
                else:
                    stmt = ('value = %s(value)' % to)
                try:
                    exec(stmt)
                except:
                    continue
            if value:
                search.add_filter(field, value, op)
def alter_search(self, search):
    field_list_option = self.get_option('field_list')
    if (not field_list_option):
        return
    stmt = ('field_info_list = %s' % field_list_option.replace('\n', ' '))
    try:
        exec(stmt)
    except:
        return
    for field_info in field_info_list:
        field = field_info.get('field')
        op = field_info.get('op')
        if (not op):
            op = '='
        if field:
            value = self.values.get(field)
            to = field_info.get('to')
            if to:
                if to.endswith('()'):
                    stmt = ('value = value.%s' % to)
                else:
                    stmt = ('value = %s(value)' % to)
                try:
                    exec(stmt)
                except:
                    continue
            if value:
                search.add_filter(field, value, op)