[Erp5-dev] SQLCatalog - search_mode fails - temporary patch

bartek bartek at erp5.pl
Tue Feb 6 10:14:56 CET 2007


Sebastien Robin wrote:
> Le Vendredi 2 Février 2007 12:31, bartek a écrit :
>> Hello
>>
>> After recent refactoring, portal_catalog fails if given search_mode
>> parameter. I think we should patch it as follows, to make it work at
>> least in a basic way (with only general search_mode setting, not per
>> column). And maybe think of a better solution - or is a more
>> comprehensive refactoring still planned?
> 
> The search_mode parameter can be different for each key, thus this parameter 
> make sense only if it is defined for some keys, like this:
> 
> portal_catalog(title={"query":'aa',"search_mode":"natural"})
> 

Thanks.

Bartek

>   Seb.
> 
> 
>> Bartek
>>
>>
>> Index: ZSQLCatalog/SQLCatalog.py
>> ===================================================================
>> --- ZSQLCatalog/SQLCatalog.py   (wersja 12218)
>> +++ ZSQLCatalog/SQLCatalog.py   (kopia robocza)
>> @@ -406,11 +406,7 @@
>>     Additionally you can pass it a search_mode argument ('natural',
>> 'in_boolean_mode'
>>     or 'with_query_expansion') to use an advanced search mode ('natural'
>>     is the default).
>> -  search_mode arg can be given for all full_text keys, or for a
>> specific key by naming
>> -  the argument search_mode_KeyName, or even more specifically,
>> search_mode_Table.Key
>> -  or search_mode_Table_Key
>>
>> -
>>     bgrain defined in meyhods...
>>
>>     TODO:
>> @@ -1707,7 +1703,7 @@
>>       key_list = [] # the list of column keys
>>       key_alias_dict = {}
>>       for key in kw.keys():
>> -      if key not in ('where_expression', 'sort-on', 'sort_on',
>> 'sort-order', 'sort_order', 'limit'):
>> +      if key not in ('where_expression', 'sort-on', 'sort_on',
>> 'sort-order', 'sort_order', 'limit', 'search_mode'):
>>           value = kw[key]
>>           current_query = None
>>           new_query_dict = {}
>> @@ -1722,7 +1718,7 @@
>>                   new_query_dict[value_key]=value[value_key]
>>             else:
>>               new_query_dict[key]=value
>> -          current_query = Query(**new_query_dict)
>> +          current_query = Query(search_mode=kw.get('search_mode'),
>> **new_query_dict)
>>           query_dict[key]=current_query
>>           key_list.extend(current_query.getSQLKeyList())
>> _______________________________________________
>> Erp5-dev mailing list
>> Erp5-dev at erp5.org
>> http://erp5.org/mailman/listinfo/erp5-dev
> 




More information about the Erp5-dev mailing list